Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Using Apache2::RequestRec and pnotes

by Krambambuli (Deacon)
on Apr 03, 2007 at 09:14 UTC ( #608010=perlquestion: print w/ replies, xml ) Need Help??
Krambambuli has asked for the wisdom of the Perl Monks concerning the following question:

Hello mod_perlers,

I've had the need recently to use mod_perl and, associated, to add some contextual information to a request during it's trip through the various stages.

I solved my rather simple problem using the "notes" method of Apache2::RecquestRec and am fine; however, the Apache2::RequestRec doc mentions 'en passant' that

...
If you want to pass Perl structures, you can use "$r->pnotes".
...

I hadn't have the time to play with that, but I'm curious about it; at first attempt, I could find no further information, so thanks for any direction/commented examples.

Thanks,
Krambambuli

Comment on Using Apache2::RequestRec and pnotes
Re: Using Apache2::RequestRec and pnotes
by TOD (Friar) on Apr 03, 2007 at 11:26 UTC
    and what's your question?
Re: Using Apache2::RequestRec and pnotes
by graq (Curate) on Apr 03, 2007 at 12:31 UTC

    If you click on that link from the online apache mod_perl docs it will take you Apache2::RequestUtil.

    Does this start you down the path of "further information.."?

    -=( Graq )=-

      Yes, thanks, that is the direction I was looking for. I just must have overseen the link to Apache2::RequestUtil, which I have ignored so far.

      Looking into it, I'm sure I'll get a few more answers to my silent concerns due to the note there:

      "See also Apache2::SafePnotes on CPAN."

      Many thanks,
      Krambambuli
Re: Using Apache2::RequestRec and pnotes
by philcrow (Priest) on Apr 03, 2007 at 13:01 UTC
    If you have $r that gets passed to the handler, you can at any phase during a single request say:
    $r->pnotes( 'name_of_struct', $hash_of_dot_dot_dot );
    Then, at any later point in the same request say:
    $r->pnotes( 'name_of_struct' );
    Phil

    Update: Fixed copy and paste mistake in referring to $r.

Re: Using Apache2::RequestRec and pnotes
by perrin (Chancellor) on Apr 03, 2007 at 14:58 UTC
    You can't store anything but a string in notes. In pnotes, you can store a ref to a hash or an object or anything else perl can store.
      Thanks, I've thought that will work like that, I'm however unsure about references to 'shared' variables hidden within the stored structures.

      But I guess I'm just a bit paranoic and most of the problems occuring with improper ways to share variables/structures within mod_perl are not as critical here, as long as I stay tied with one specific request.

      I'll definitely will need to play a bit with it myself in order to 'feel' it.

      Many thanks,
      Krambambuli
        I'm not sure what the "shared" references you're referring to are, but there is no sharing of notes or pnotes between child processes. It also gets cleaned up automatically at the end of the request, which is very convenient.
Re: Using Apache2::RequestRec and pnotes
by Moron (Curate) on Apr 03, 2007 at 16:55 UTC
    re "En Passant" You can mention something "in passing" but the literal French version "en passant" only has technical meanings in English such as taking a piece "en passant" in chess, or bringing off a "coup en passant" at the game of bridge.

    okay it isn't a Perl problem with it, but it stuck out at me and I just had to bite (update: ... said the actress to the bishop).

    -M

    Free your mind

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-08-28 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls