Denis Banovic wrote:
Hi!

I'm trying to migrate some stuff from mod_perl 1.
I've read the tutorial on perl.apache.org but it didn't help.

I've a perl script that looks like this:

if ($runnung_on_mod_perl) {
        Apache->request->register_cleanup(\&init_globals);
}

Under mod_perl 1.0 works fine with Apache::Registry.


But I can't find out how to port this to mod_perl 2.


I've tried to use

Apache::compat();  but then I got another error from an Module we are using
to cache the script's output:

"ModPerl::Registry: anonymous handlers not (yet) supported at..."

It's not an error in your code, anon callbacks aren't implemented yet.


$self->{r}->push_handlers(PerlHandler => sub {$self->DESTROY});

that should be PerlCleanupHandler, btw. even though it doesn't work yet.


1) How to do a register_cleanup with mod_perl 2.0 ?

If you are asking about requests cleanup it's one of these:


sub my_cleanup {...}
$r->pool->cleanup_register(\&my_cleanup);
$r->pool->cleanup_register('my_cleanup');
$r->pool->cleanup_register(sub {...}); # anon subs do work here!
$r->push_handlers(PerlCleanupHandler => \&my_cleanup);
$r->push_handlers(PerlCleanupHandler => 'my_cleanup');

Also, your original 1.x code:

> if ($runnung_on_mod_perl) {
>    Apache->request->register_cleanup(\&init_globals);
> }

should work unmodified, under Apache::compat.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to