Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: mod_perl and forwarding legacy functions to a global object

by Fletch (Chancellor)
on Jun 25, 2004 at 17:53 UTC ( #369691=note: print w/replies, xml ) Need Help??


in reply to mod_perl and forwarding legacy functions to a global object

Create an instance in an init handler and stash it in $r->notes. Write procedural wrappers which retrieve that instance and call the appropriate methods. That instance will only exist for the lifetime of the one request.

Addendum: This also has the advantage of allowing new code to access the already existent instance and call the methods directly as well (either by using an already existing request record or by using Apache->request->notes).

Update: Ooop, as is pointed out below I meant pnotes which lets you store an arbitrary perl value. That's what one gets after getting spoiled by HTML::Mason doing everything for you. :)

Replies are listed 'Best First'.
Re^2: mod_perl and forwarding legacy functions to a global object
by elusion (Curate) on Jun 25, 2004 at 18:15 UTC
    Beautiful. Thank you. Apache->request->notes only stores strings, but I was able to store a flag that let me know if I'd created an object for that instance.
      pnotes allows you to store a reference to a data structure.

      -derby

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://369691]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2019-11-20 14:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (97 votes). Check out past polls.

    Notices?