I'm still concerned about the 4 responses for only 3 calls as I am certain there are only 3. I've been playing with this in a very small program so it's hard to miss any.
I was thinking overnight and the only thing I could come up with was that the pre-loading I'm doing in the traditional startup.pl might be having some effect. Is this possible? > -----Original Message----- > From: Perrin Harkins [mailto:[EMAIL PROTECTED] > Sent: Friday, 10 October 2003 1:36 AM > To: Morton-Allen, Matt > Cc: [EMAIL PROTECTED] > Subject: RE: Using class wide variables under mod_perl is safe? > > 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