You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mark Maunder <ma...@ziptree.com> on 2003/07/17 04:37:03 UTC

pnotes and notes not working from Apache::Registry to handler

Hi,

I'm trying to store data about a user who has authenticated in
$r->pnotes so that a perl logging phase handler can stick the user_id in
the db. I call $r->pnotes('keyname' => 'somevalue'); in an apache
registry script, and then call $r->pnotes('keyname') in the logging
handler later on during the logging phase, but am getting nothing back.
No errors, just undef. I've tried notes too, and no luck their either.
I'm using Apache::Request btw. I've also tried retreiving a tied hash
using $r->pnotes() and there are no key/values in that either.

Is it possible to use pnotes to pass data from an Apache::Registry
script to a handler? Perhaps thats the prob - didn't find anything that
said otherwise.

Did I forget to compile apache or mod_perl with an option of some sort?
I can't think of any other explanation. I compiled mod_perl with
EVERYTHING=1

Thanks,

Mark.



Re: pnotes and notes not working from Apache::Registry to handler

Posted by Mark Maunder <ma...@ziptree.com>.
Found this piece of info in the archives. I'm also running 1.27. Is this
a known bug?

http://groups.yahoo.com/group/modperl/message/45472
*snip*
Subject:  notes/pnotes broke between 1.25=>1.27


So I got the advisory about the Apache servers having a security hole,
so I
decided to upgrade some servers. I've been on v1.25 for awhile, so
decided
to upgrade to 1.27 while I was at it... big mistake.

NONE of my notes/pnotes were getting thru, on the new version.
*snip*

On Wed, 2003-07-16 at 19:37, Mark Maunder wrote:
> Hi,
> 
> I'm trying to store data about a user who has authenticated in
> $r->pnotes so that a perl logging phase handler can stick the user_id in
> the db. I call $r->pnotes('keyname' => 'somevalue'); in an apache
> registry script, and then call $r->pnotes('keyname') in the logging
> handler later on during the logging phase, but am getting nothing back.
> No errors, just undef. I've tried notes too, and no luck their either.
> I'm using Apache::Request btw. I've also tried retreiving a tied hash
> using $r->pnotes() and there are no key/values in that either.
> 
> Is it possible to use pnotes to pass data from an Apache::Registry
> script to a handler? Perhaps thats the prob - didn't find anything that
> said otherwise.
> 
> Did I forget to compile apache or mod_perl with an option of some sort?
> I can't think of any other explanation. I compiled mod_perl with
> EVERYTHING=1
> 
> Thanks,
> 
> Mark.
-- 
Mark Maunder <ma...@ziptree.com>
ZipTree Inc.


Re: pnotes and notes not working from Apache::Registry to handler

Posted by Mark Maunder <ma...@ziptree.com>.
thanks. :)

I've ploughed through the manual and I'm pretty sure I've been trying
both notes and pnotes correctly. There's also a fairly common mistake of
assuming you're dealing with the initial request, when in fact
Apache->request is a sub-request and you need to use $r->main to
retrieve the main request to access your pnotes. I'm not making that
mistake either. 

The last option you mention about mod_perl compilation options: I've
compiled with EVERYTHING=1 and I even grep'd the apache and mod_perl
source just now for 'pnotes' to see if I could spot anything. Nothing
popped out at me. 

I'll try to recompile with
PLUS_THAT_OTHER_LITTLE_THING_NOT_INCLUDED_IN_EVERYTHING=1 now and see if
I have better luck ;)

On Wed, 2003-07-16 at 22:58, Dennis Stout wrote:
> > I'm trying to store data about a user who has authenticated in
> > $r->pnotes so that a perl logging phase handler can stick the user_id in
> > the db. I call $r->pnotes('keyname' => 'somevalue'); in an apache
> > registry script, and then call $r->pnotes('keyname') in the logging
> > handler later on during the logging phase, but am getting nothing back.
> > No errors, just undef. I've tried notes too, and no luck their either.
> > I'm using Apache::Request btw. I've also tried retreiving a tied hash
> > using $r->pnotes() and there are no key/values in that either.
> 
> the mod_perl API book specifically said pnotes is the way to communicate
> between handlers.  As I have hte PDF version, I can't exactly cut & paste it
> easily...
> 
> pnotes gets cleared after every request, so good thinking on trying notes, as
> it apearently doesn't.
> 
> the basic usage is this:
> 
> $r->pnotes("MY_HANDLER" => [qw(one two)]);
> my $val = $r->pnotes("MY_HANDLER");
> print $val->[0]; # prints "one"
> 
> So basically, $r->pnotes("MY_HANDLER" => [qw(one two)]); will create a hash
> where MY_HANDLER is a key to an anonymous array.
> 
> my $val = $r->pnotes("MY_HANDLER"); sets $val to be the reference to that
> array.
> 
> print $val->[0]; dereferences the first spot in the array reference.  The
> dereferencing thing is key here.  $val[0] will throw errors about globals not
> being declared as arrays or something of that sort.
> 
> 
> > Did I forget to compile apache or mod_perl with an option of some sort?
> > I can't think of any other explanation. I compiled mod_perl with
> > EVERYTHING=1
> 
> There is the problem right there.  It needs to be compiled with "EVERYTHING=1
> PLUS_THAT_OTHER_LITTLE_THING_NOT_INCLUDED_IN_EVERYTHING=1".
> 
> :P
> 
> Dennis
-- 
Mark Maunder <ma...@ziptree.com>
ZipTree Inc.


Re: pnotes and notes not working from Apache::Registry to handler

Posted by Dennis Stout <st...@stout.dyndns.org>.
> I'm trying to store data about a user who has authenticated in
> $r->pnotes so that a perl logging phase handler can stick the user_id in
> the db. I call $r->pnotes('keyname' => 'somevalue'); in an apache
> registry script, and then call $r->pnotes('keyname') in the logging
> handler later on during the logging phase, but am getting nothing back.
> No errors, just undef. I've tried notes too, and no luck their either.
> I'm using Apache::Request btw. I've also tried retreiving a tied hash
> using $r->pnotes() and there are no key/values in that either.

the mod_perl API book specifically said pnotes is the way to communicate
between handlers.  As I have hte PDF version, I can't exactly cut & paste it
easily...

pnotes gets cleared after every request, so good thinking on trying notes, as
it apearently doesn't.

the basic usage is this:

$r->pnotes("MY_HANDLER" => [qw(one two)]);
my $val = $r->pnotes("MY_HANDLER");
print $val->[0]; # prints "one"

So basically, $r->pnotes("MY_HANDLER" => [qw(one two)]); will create a hash
where MY_HANDLER is a key to an anonymous array.

my $val = $r->pnotes("MY_HANDLER"); sets $val to be the reference to that
array.

print $val->[0]; dereferences the first spot in the array reference.  The
dereferencing thing is key here.  $val[0] will throw errors about globals not
being declared as arrays or something of that sort.


> Did I forget to compile apache or mod_perl with an option of some sort?
> I can't think of any other explanation. I compiled mod_perl with
> EVERYTHING=1

There is the problem right there.  It needs to be compiled with "EVERYTHING=1
PLUS_THAT_OTHER_LITTLE_THING_NOT_INCLUDED_IN_EVERYTHING=1".

:P

Dennis