Hello,
I'm writing a pure-Perl Apache 2 module that installs a few custom directives. Four of the directives are only useful in the server root (i.e. outside of any VirtualHost, Directory, etc. directives), but three others make sense within containers.


The directives seem to parse correctly, but when I try to access the configuration structure from a PostConfigHandler or ChildInitHandler, the resulting structure contains the default configuration, as if the directives had never been parsed at all. (I want a PostConfigHandler because I need to fork off a single background process for the entire server, and that seems like the easiest way to do so.)

At the very least, I'm looking for a good example of a module that does something like this, but if someone can help me with the specific problem I'm having, that'd be even better.

Some (possibly) relevant bits of code follow...

    our @APACHE_MODULE_COMMANDS=(
        {
            name => 'RegulateDatabase',
            args_how => Apache::TAKE123,
            req_override => Apache::RSRC_CONF,
            errmsg => 'RegulateDatabase connectionstring [username
            [password]]'
        },
        ...
    );

    sub SERVER_CREATE {
        return bless {
            Database    => ['DBI:mysql:Regulate'],
            ...
        }, shift;
    }

    sub DIR_CREATE {
        return bless {
            ...
        }, shift;
    }

    sub SERVER_MERGE {
        my($base, $add)[EMAIL PROTECTED];
        return bless { %$add, %$base }, ref $base;
    }

    sub DIR_MERGE {
        my($base, $add)[EMAIL PROTECTED];
        return bless { %$add, %$base }, ref $base;
    }

    sub RegulateDatabase {
        my($self, $params, @args)=(@_);
        $self->[EMAIL PROTECTED];
    }

    sub global_init #:PostConfigHandler
    {
        my(undef, undef, undef, $s)[EMAIL PROTECTED];
        my $conf=Apache::Module->get_config(__PACKAGE__, $s);
        ...
        my $dbh=DBI->connect(@{$conf->{Database}}, {RaiseError=>1}) or
            die $DBI::errstr;
    }

Even with a line in my httpd.conf like:
    PerlLoadModule Apache::Regulate
    RegulateDatabase 'dbi:mysql:apache' apache [redacted]

global_init() dies with this error:
    DBI connect('Regulate','HASH(0x8a377ec)',...) failed: Access denied
    for user: '@localhost' to database 'Regulate'

Which leads me to believe that either the information isn't being recorded for some reason, or I'm looking at the wrong $conf structure.

Any help, even just a pointer to a module that does something like this, would be much appreciated. In the mean time, I guess I'll hardwire the values I want and continue testing...

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker

Oceania has always been at war with Eastasia.

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to