From: Tomas Doran Date: Mon, 8 Mar 2010 00:56:38 +0000 (+0000) Subject: Don't break the calling convention for the run method by making the server the last... X-Git-Tag: 5.89000~32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=4b0f97fc6eb94b7d347403cecbf9a71ec5322e37;hp=a98940b5ca887252a3e0132581417e6abf7ee331 Don't break the calling convention for the run method by making the server the last argument, ignore Engine::HTTP, prepend Catalyst::Engine if needed. This all makes TWMC somewhat less broken. --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 06130d1..02b5d60 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2378,6 +2378,10 @@ sub setup_engine { unless ($engine) { $engine = $class->engine_class; } + $engine = 'Catalyst::Engine::' . $engine + unless $engine =~ /^Catalyst::Engine/; + + $engine = 'Catalyst::Engine' if $engine eq 'Catalyst::Engine::HTTP'; Class::MOP::load_class($engine); diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 0152ebf..e6c5d62 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -752,12 +752,14 @@ run method on the server passed in.. =cut sub run { - my ($self, $app, $server, @args) = @_; + my ($self, $app, @args) = @_; + my $server = pop @args if blessed $args[-1]; $server ||= Plack::Loader->auto(); # We're not being called from a script, # so auto detect what backend to run on. # This does *NOT* cover mod_perl. # FIXME - Do something sensible with the options we're passed - $server->run($self->build_psgi_app($app, @args)); + my $psgi = $self->build_psgi_app($app, @args); + $server->run($psgi); } =head2 build_psgi_app ($app, @args) diff --git a/lib/Catalyst/ScriptRole.pm b/lib/Catalyst/ScriptRole.pm index af47fd2..e36ca2f 100644 --- a/lib/Catalyst/ScriptRole.pm +++ b/lib/Catalyst/ScriptRole.pm @@ -72,7 +72,7 @@ sub _run_application { else { $server = Plack::Loader->auto($self->_plack_loader_args); } - $app->run($server, $self->_application_args); + $app->run($self->_application_args, $server); } 1;