[Catalyst] RESOLVED Catalyst modperl2 Problem

bsadler at helix-it.com bsadler at helix-it.com
Fri Apr 1 23:16:41 CEST 2005


Hi all,

After lots of tracing around the code I have resolved the Apache2/ModPerl2
problem.

Basically what happens is that modperl2 does not call handler as a method (with
$self as the first argument) by default.

In order to fix this I added the following to Catalyst::Engine::Apache

sub handler_mp1($$) {
        my $class = shift;
        $class->SUPER::handler(@_);
}

eval {
        sub handler_mp2 : method {
                my $class = shift;
                $class->SUPER::handler(@_);
        }
};

if($@) {
  *handler = \&handler_mp1;
} else {
  *handler = MP2 ? \&handler_mp2 : \&handler_mp1;
}

The above should behave correctly in either modperl1 or modperl2, but it is
untested under modperl1 as I do not have a modperl1 server handy.

The modperl2 handler uses a new language feature as of perl 5.6.0 so I eval it
and silently go to the modperl1 handler if I get an error.

If you want to use modperl2 with perl < 5.6.0 then may god have mercy on your
soul. Actually you can just put sub handler { MyApp->SUPER::handler(@_); } in
each application module where MyApp is the fully qualified package name, but
that's just ugly.

Cheers,

Blain








More information about the Catalyst mailing list