Ok, much joy and happiness, it works (not that I doubted you!). For now I have taken out the pre-loading as it seems to result in deep voodoo that I don't claim to understand.
One last question, which I am certain is obvious but is passing me by. How can I get this to work under CGI? As I mentioned earlier I tend to use CGI for early development so I know what I am dealing with. Matt. > -----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