Hello,

I am writing a new mod_perl Apache (mod_perl2) to manage session tracking
and SSO
This module defines a new Apache directive (MyNewDirective), which is usable
in a <location>, <files><directory> block.

For example
<Location /a_test>
    Set-Handler perl-script
    MyNewDirective a_test arg1 arg2
    PerlResponseHandler ResponseHandlerToTestTheNewDirective
</Location>
<Location /another_test>
    Set-Handler perl-script
    PerlResponseHandler ResponseHandlerToTestTheNewDirective
</Location>


When this directive is used, my module should a PerlLogHandler automatically
to obtain the following configuration
<Location /a_test>
    Set-Handler perl-script
    MyNewDirective a_test arg1 arg2
    PerlResponseHandler ResponseHandlerToTestTheNewDirective
    PerlLogHandler TestPerlLogHandler
</Location>
<Location /another_test>
    Set-Handler perl-script
    PerlResponseHandler ResponseHandlerToTestTheNewDirective
</Location>

I tried to use the push_handler method when the 'MyNewDirective' is defined.

my @directives = ({name => 'MyNewDirective ', func =>
__PACKAGE__.'::MyNewDirective'});

Apache2::Module::add(__PACKAGE__, [EMAIL PROTECTED]);

sub MyNewDirective {
    my ($self, $parms, $arg) = @_;

    # blablabla

    $parms->server->push_handlers(PerlLogHandler => sub {my ($r) _ @_;
$r->server->error_log('hello world'); return Apache2::Const::OK;});

    # blablabla
    return;
}

This code works ... but for any blocks.
For example, if I access the URI '/a_test', the PerlLogHandler will be
called BUT if I access the URI '/another_test', the PerlLogHandler will also
be called.

Do I use the mod_perl API correctly ?
What is wrong in my code ?

Thanks.

Gaetan

Reply via email to