[Catalyst-commits] r13939 - in Catalyst-Runtime/5.80/branches/psgi:
. lib lib/Catalyst lib/Catalyst/Engine
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Mon Jan 31 09:16:11 GMT 2011
Author: t0m
Date: 2011-01-31 09:16:11 +0000 (Mon, 31 Jan 2011)
New Revision: 13939
Modified:
Catalyst-Runtime/5.80/branches/psgi/Changes
Catalyst-Runtime/5.80/branches/psgi/TODO
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst.pm
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine.pm
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine/Loader.pm
Log:
Fix Engine::Stomp with psgi
Modified: Catalyst-Runtime/5.80/branches/psgi/Changes
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/Changes 2011-01-31 08:25:12 UTC (rev 13938)
+++ Catalyst-Runtime/5.80/branches/psgi/Changes 2011-01-31 09:16:11 UTC (rev 13939)
@@ -1,5 +1,8 @@
# This file documents the revision history for Perl extension Catalyst.
+ - Fixed Catalyst::Engine::Stomp
+ - Fixed issues auto-loading engine with older scripts.
+
5.89000 2011-01-24 09:28:45 (TRIAL release)
This is a development release from psgi branch of Catalyst-Runtime.
Modified: Catalyst-Runtime/5.80/branches/psgi/TODO
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/TODO 2011-01-31 08:25:12 UTC (rev 13938)
+++ Catalyst-Runtime/5.80/branches/psgi/TODO 2011-01-31 09:16:11 UTC (rev 13939)
@@ -35,7 +35,7 @@
* Add some tests for Catalyst::Test::local_request
* Docs
* Test all the options work on all of the scripts
- * Test (and fix if needed) Engine::Stomp and ::Wx
+ * Test (and fix if needed) ::Wx
* Document how to use your own .psgi (and how you need to do ReverseProxy yourself if you do)
* Document migration for setting engine in setup
* Document migration for setting engine in $ENV
Modified: Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine/Loader.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine/Loader.pm 2011-01-31 08:25:12 UTC (rev 13938)
+++ Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine/Loader.pm 2011-01-31 09:16:11 UTC (rev 13939)
@@ -12,6 +12,27 @@
required => 1,
);
+has catalyst_engine_class => (
+ isa => 'Str',
+ is => 'rw',
+ lazy => 1,
+ builder => '_guess_catalyst_engine_class',
+);
+
+sub _guess_catalyst_engine_class {
+ my $self = shift;
+ my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE');
+ if (!defined $old_engine) {
+ return 'Catalyst::Engine';
+ }
+ elsif ($old_engine =~ /^(CGI|FCGI|HTTP|Apache.*)$/) {
+ return 'Catalyst::Engine';
+ }
+ elsif (my ($type) = $old_engine =~ /^(Stomp|Test::MessageDriven|Wx)$/) {
+ return 'Catalyst::Engine::' . $type;
+ }
+}
+
around guess => sub {
my ($orig, $self) = (shift, shift);
my $engine = $self->$orig(@_);
Modified: Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine.pm 2011-01-31 08:25:12 UTC (rev 13938)
+++ Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine.pm 2011-01-31 09:16:11 UTC (rev 13939)
@@ -791,10 +791,11 @@
# FIXME - we should stash the options in an attribute so that custom args
# like Gitalist's --git_dir are possible to get from the app without stupid tricks.
- my $server = pop @args if blessed $args[-1];
- my $options = pop @args if ref($args[-1]) eq 'HASH';
+ my $server = pop @args if (scalar @args && blessed $args[-1]);
+ my $options = pop @args if (scalar @args && ref($args[-1]) eq 'HASH');
if (! $server ) {
- $server = Catalyst::Engine::Loader->auto(); # We're not being called from a script,
+ $server = Catalyst::Engine::Loader->new(application_name => ref($self))->auto();
+ # We're not being called from a script,
# so auto detect what backend to run on.
# This should never happen, as mod_perl
# never calls ->run, instead the $app->handle
Modified: Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst.pm 2011-01-31 08:25:12 UTC (rev 13938)
+++ Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst.pm 2011-01-31 09:16:11 UTC (rev 13939)
@@ -30,6 +30,7 @@
use List::MoreUtils qw/uniq/;
use attributes;
use String::RewritePrefix;
+use Catalyst::Engine::Loader;
use utf8;
use Carp qw/croak carp shortmess/;
use Try::Tiny;
@@ -70,11 +71,10 @@
#maybe we should just make them attributes with a default?
__PACKAGE__->mk_classdata($_)
for qw/components arguments dispatcher engine log dispatcher_class
- engine_class context_class request_class response_class stats_class
+ engine_loader context_class request_class response_class stats_class
setup_finished _psgi_app/;
__PACKAGE__->dispatcher_class('Catalyst::Dispatcher');
-__PACKAGE__->engine_class('Catalyst::Engine');
__PACKAGE__->request_class('Catalyst::Request');
__PACKAGE__->response_class('Catalyst::Response');
__PACKAGE__->stats_class('Catalyst::Stats');
@@ -2589,20 +2589,26 @@
=cut
+sub engine_class {
+ my $class = shift;
+ $class->engine_loader->catalyst_engine_class(@_);
+}
+
sub setup_engine {
my ($class) = @_;
+ $class->engine_loader(Catalyst::Engine::Loader->new(application_name => $class));
+
my $engine = $class->engine_class;
Class::MOP::load_class($engine);
if ($ENV{MOD_PERL}) {
- require 'Catalyst/Engine/Loader.pm';
- my $apache = Catalyst::Engine::Loader->auto;
+ my $apache = $class->engine_loader->auto;
# FIXME - Immutable
$class->meta->add_method(handler => sub {
my $r = shift;
- my $app = $class->psgi_app;
- $apache->call_app($r, $app);
+ my $psgi_app = $class->psgi_app;
+ $apache->call_app($r, $psgi_app);
});
}
More information about the Catalyst-commits
mailing list