On Friday, August 15, 2003, at 12:43 PM, Ged Haywood wrote:
I'm not entirely convinced of the explanation, but have you tried
testing the value of $Apache::Server::ReStarting in the code that
fills the hash?  It's in the Guide.

I'm not convinced of it either. :)


This code _would_ run twice, so I can protect it using the variable you specified. I didn't know it existed. List messages seem to say that this shouldn't be used?

Your message was a bit cavalier about what's a hash and what's a
hashref, are you sure you aren't just missing a dereference somewhere?
Have you got 'use strict' and warnings on.

It's a difficult concept to relay without pasting a bunch of code.


-- App.pm:

package App;

my %pageobjs;

sub loadApp {
        my $self = shift();
        my $name = shift();
        my $libdir = shift();

my %pages;
opendir(LIBDIR, $libdir);
while(there are files to check) {
# blah, if the file is a .pm, require and instantiate it into $page
$pages{$pageObjectName} = $page;
closedir(LOBDIR);
$pageobjs{$name} = \%pages;
}


sub getPages {
        my $self = shift();
     my $name = shift();

        return $pageobjs{$name};
}

-- startup.pl:

use App;

Sooo, using the above code, the VHost uses:

PerlVar app blah
<Perl>
 App->loadApp("blah", "/usr/local/blah/lib");
</Perl>

And, inside the Handler:

my $app = $r->dir_config("app");
my $hashRefOfPageObjs = App->getPages($app);

And $hashRefOfPageObjs is always undef;

Ignore syntax errors and lack of declarations, as I just threw that together from memory into the ol' MUA here. Does that make more sense? I believe I had this working at one point, but something has caused it go south. The double load I see (which you explained with your Restarting tip) was suspect only because if I put code into App which Data::Dumper's the hash, there is something in it, but it disappears between the first load and the first request. It looks like <Perl> sections are executed twice, but this shouldn't cause the variable to go undefined.

Cory 'G' Watson
http://www.loggerithim.org



--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Reply via email to