X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=708c005f82912d5a97e367916be55da0db177167;hb=0f7ecc537d7a258023b1a58311f197ad5dca24c7;hp=90d158af0d91d153a8bb5af8d6e7deada777bc50;hpb=32e4cad6b4d17819d58bf80f4ef473231d70df7b;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 90d158a..708c005 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -4,6 +4,7 @@ use strict; use base 'Catalyst::Base'; use UNIVERSAL::require; use Catalyst::Log; +use Text::ASCIITable; __PACKAGE__->mk_classdata($_) for qw/engine log/; @@ -144,11 +145,19 @@ sub import { $caller->log->debug('Debug messages enabled'); } - # Options - my $engine = - $ENV{MOD_PERL} - ? 'Catalyst::Engine::Apache' - : 'Catalyst::Engine::CGI'; + my $engine = 'Catalyst::Engine::CGI'; + + if ( $ENV{MOD_PERL} ) { + + require mod_perl; + + if ( $mod_perl::VERSION >= 1.99 ) { + $engine = 'Catalyst::Engine::Apache::MP2'; + } + else { + $engine = 'Catalyst::Engine::Apache::MP1'; + } + } my @plugins; foreach (@options) { @@ -163,19 +172,22 @@ sub import { else { my $plugin = "Catalyst::Plugin::$_"; - # Plugin caller should be our application class - eval "package $caller; require $plugin"; + $plugin->require; + if ($@) { $caller->log->error(qq/Couldn't load plugin "$plugin", "$@"/); } else { - push @plugins, " $plugin"; + push @plugins, " + $plugin"; no strict 'refs'; push @{"$caller\::ISA"}, $plugin; } } } - $caller->log->debug( 'Loaded plugins', @plugins ) + my $t = Text::ASCIITable->new; + $t->setCols('Class'); + $t->addRow($_) for @plugins; + $caller->log->debug( 'Loaded plugins', $t->draw ) if ( @plugins && $caller->debug ); # Engine