On Thu, 2003-10-09 at 00:56, Morton-Allen, Matt wrote:
> I should have also mentioned that not only does the "returned" come back
> out of order there are also more than there should be. There's 3 calls
> and 4 results.
Then there's probably another call that you didn't notice.
> Worse it now appears that if I hit the server long enough to come back
> to the same process the value has stayed put. I assume this is why the
> suggested use of $r->pnotes?
Right.
> If so how do I get access to $r (which is shifted off early in the .pl)
> when this is deep within a module (without a global that is)?
Well, again, there's nothing wrong with globals when used carefully, and
this solution does use them for storing things.
If you're using mod_perl 1, you can do this to get $r:
my $r = Apache->request();
If you're using mod_perl 2, you can do this:
# in your handler
my $r = shift;
Matt::Resources->set_req($r);
# in Matt::Resources
our $r;
sub set_req {
$r = shift;
}
sub get_dbh {
if (!$r->pnotes('dbh')) {
my $dbh = DBI->connect...
$r->pnotes('dbh', $dbh);
}
return $r->pnotes('dbh');
}
- Perrin