Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: mod_perl and forwarding legacy functions to a global object

by Fletch (Bishop)
on Jun 25, 2004 at 17:53 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://369691]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-19 02:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found