Re: push_handler with Apache::ModuleConfig

[prev] [thread] [next] [Date index for 2004/11/19]

From: Geoffrey Young
Subject: Re: push_handler with Apache::ModuleConfig
Date: 15:19 on 19 Nov 2004

Xavier wrote:
> Hello,
> 
> for best look, I'd like to replace :
> 
> PerlInitHandler My::Module
>   with
> MyModule On

these are not the same thing, so they will not have the same effect.

both are parsed and executed only once - when you start the server. well,
ok, twice, but who's counting :)  they will also be executed each time you
restart the server.

however, the PerlInitHandler directive tells mod_perl to run My::Module for
each request during the post-read phase.  a custom directive will not be
able to do that for you.

> 
> I've done the XS file using Apache::ExtUtils, but I don't know how to
> write the "MyModule" sub. Is there any entry in the $cfg object to do it?
> 
> sub MyModule {
>     my($cfg,$parms,$arg)=@_;
>     $cfg->{__WHAT__} = \&myhandler if($arg);
> }
> 
> With Google, I've found scripts using "$cfg->{handler}", but they're
> calling a standard handler, not a Perl one; I've neither found any doc
> about the "per-directory/server" $cfg class.

perl directive handlers are _only_ an access to the httpd.conf parsing
process - they do not register your module nor tell it when to run.
therefore you will always need two directives if you want some request-time
action.  at least not with mod_perl 1.0 - in mp2 you should be able to use
Apache::Module::add_config to push the PerlInitHandler into the config for you.

see recipes 7.8, 7.10, and 7.11 for a few more examples of using directive
handlers:

  http://www.modperlcookbook.org/chapters/ch07.pdf

the code for each of these is also available

  http://www.modperlcookbook.org/code/ch07/

HTH

--Geoff

        -- 
        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

push_handler with Apache::ModuleConfig
Xavier 18:18 on 16 Nov 2004

Re: push_handler with Apache::ModuleConfig
Geoffrey Young 15:19 on 19 Nov 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52