From: Tomas Doran Date: Sat, 6 Aug 2011 15:12:02 +0000 (+0100) Subject: Fix custom engine compat X-Git-Tag: 5.9000~10^2~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=a8153308d08f22bb044515c822f973fe8680d213 Fix custom engine compat --- diff --git a/Changes b/Changes index b2aea32..38658f3 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ # This file documents the revision history for Perl extension Catalyst. + Backward compatibility fixes: + + - Fix calling MyApp->engine_class to set the engine class manually. + 5.89003 2011-07-28 20:11:50 (TRIAL release) Backward compatibility fixes: diff --git a/TODO b/TODO index 0e5050d..7c2e894 100644 --- a/TODO +++ b/TODO @@ -37,7 +37,6 @@ http://github.com/willert/catalyst-plugin-log4perl-simple/tree * Fix nginx middlewares so that they are generic, or can somehow be used by people with their own .psgi files - * Fix a sane / nicer way to do custom engines. * I've noticed a small difference with Catalyst::Test. The latest stable version include two headers, 'host' and 'https'. They are missing from diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 5626071..a4278fd 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2603,26 +2603,28 @@ Sets up engine. =cut sub engine_class { - my $class = shift; - confess("Setting ->engine_class manually is no longer supported. XXX FIXME") if scalar @_; + my ($class, $requested_engine) = @_; + + if (!$class->engine_loader || $requested_engine) { + $class->engine_loader( + Catalyst::EngineLoader->new({ + application_name => $class, + (defined $requested_engine + ? (requested_engine => $requested_engine) : ()), + }), + ); + } $class->engine_loader->catalyst_engine_class; } sub setup_engine { my ($class, $requested_engine) = @_; - $class->engine_loader( - Catalyst::EngineLoader->new({ - application_name => $class, - (defined $requested_engine - ? (requested_engine => $requested_engine) : ()), - }), - ); + my $engine = $class->engine_class($requested_engine); # Don't really setup_engine -- see _setup_psgi_app for explanation. return if $class->loading_psgi_file; - my $engine = $class->engine_class; Class::MOP::load_class($engine); if ($ENV{MOD_PERL}) {