[Catalyst-commits] r13311 - 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 May 24 15:44:11 GMT 2010
Author: t0m
Date: 2010-05-24 16:44:11 +0100 (Mon, 24 May 2010)
New Revision: 13311
Added:
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine/
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine/Loader.pm
Modified:
Catalyst-Runtime/5.80/branches/psgi/
Catalyst-Runtime/5.80/branches/psgi/Makefile.PL
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst.pm
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/ScriptRole.pm
Log:
r15606 at spaceinvaders: t0m | 2010-05-23 14:16:14 +0100
Put some of the mod_perl code back. This is pretty much untested and won't work, but is a start
Property changes on: Catalyst-Runtime/5.80/branches/psgi
___________________________________________________________________
Modified: svk:merge
- 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8533
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates:8363
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/add_captures_to_visit:9546
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/aggregate_more:11803
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/better_scripts:12074
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/disable_regex_fallback:11456
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_path_info_decoding:12089
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_request_uri:13262
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/index_default_fuckage:10646
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/more_metaclass_compat:13280
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/namespace_handling_refactor:10655
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/param_filtering:13012
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_encode_captures_andor_args_take2:11811
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_for_utf8:12834
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/trunk:13297
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-better_scripts:11331
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-mech_tests:15583
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-psgi:15605
8a9521aa-ff93-41d6-9f87-b05cafcdab40:/local/cat/Catalyst-Runtime/5.80/trunk:8157
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
+ 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8533
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates:8363
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/add_captures_to_visit:9546
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/aggregate_more:11803
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/better_scripts:12074
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/disable_regex_fallback:11456
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_path_info_decoding:12089
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_request_uri:13262
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/index_default_fuckage:10646
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/more_metaclass_compat:13280
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/namespace_handling_refactor:10655
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/param_filtering:13012
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_encode_captures_andor_args_take2:11811
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_for_utf8:12834
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/trunk:13297
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-better_scripts:11331
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-mech_tests:15583
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-psgi:15606
8a9521aa-ff93-41d6-9f87-b05cafcdab40:/local/cat/Catalyst-Runtime/5.80/trunk:8157
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
Modified: Catalyst-Runtime/5.80/branches/psgi/Makefile.PL
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/Makefile.PL 2010-05-24 15:44:09 UTC (rev 13310)
+++ Catalyst-Runtime/5.80/branches/psgi/Makefile.PL 2010-05-24 15:44:11 UTC (rev 13311)
@@ -23,6 +23,7 @@
requires 'Moose' => '1.03';
requires 'MooseX::MethodAttributes::Inheritable' => '0.19';
requires 'MooseX::Role::WithOverloading' => '0.05';
+requires 'MooseX::Types::LoadableClass' => '0.003';
requires 'Carp';
requires 'Class::C3::Adopt::NEXT' => '0.07';
requires 'CGI::Simple::Cookie' => '1.109';
Added: Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine/Loader.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine/Loader.pm (rev 0)
+++ Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Engine/Loader.pm 2010-05-24 15:44:11 UTC (rev 13311)
@@ -0,0 +1,42 @@
+package Catalyst::Engine::Loader;
+use Moose;
+use Catalyst::Exception;
+use namespace::autoclean;
+
+extends 'Plack::Loader';
+
+around guess => sub {
+ my ($orig, $self) = (shift, shift);
+ my $engine = $self->$orig(@_);
+ if ($engine eq 'Standalone') {
+ if ( $ENV{MOD_PERL} ) {
+ my ( $software, $version ) =
+ $ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/;
+
+ $version =~ s/_//g;
+ if ( $software eq 'mod_perl' ) {
+ if ( $version >= 1.99922 ) {
+ $engine = 'Apache2';
+ }
+
+ elsif ( $version >= 1.9901 ) {
+ Catalyst::Exception->throw( message => 'Plack does not have a mod_perl 1.99 handler' );
+ $engine = 'Apache2::MP19';
+ }
+
+ elsif ( $version >= 1.24 ) {
+ $engine = 'Apache1';
+ }
+
+ else {
+ Catalyst::Exception->throw( message =>
+ qq/Unsupported mod_perl version: $ENV{MOD_PERL}/ );
+ }
+ }
+ }
+ }
+ return $engine;
+};
+
+__PACKAGE__->meta->make_immutable( inline_constructor => 0 );
+1;
Modified: Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/ScriptRole.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/ScriptRole.pm 2010-05-24 15:44:09 UTC (rev 13310)
+++ Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/ScriptRole.pm 2010-05-24 15:44:11 UTC (rev 13311)
@@ -3,7 +3,8 @@
use MooseX::Types::Moose qw/Str Bool/;
use Pod::Usage;
use MooseX::Getopt;
-use Plack::Loader;
+use Catalyst::Engine::Loader;
+use MooseX::Types::LoadableClass qw/LoadableClass/;
use namespace::autoclean;
with 'MooseX::Getopt' => {
@@ -29,6 +30,26 @@
cmd_aliases => ['?', 'h'],
);
+has loader_class => (
+ isa => LoadableClass,
+ is => 'ro',
+ coerce => 1,
+ default => 'Catalyst::Engine::Loader',
+ documentation => 'The class to use to detect and load the PSGI engine',
+);
+
+has _loader => (
+ isa => 'Plack::Loader',
+ default => sub {
+ shift->loader_class->new
+ },
+ handles => {
+ load_engine => 'load',
+ autoload_engine => 'auto',
+ },
+ lazy => 1,
+);
+
sub _getopt_spec_exception {}
sub _getopt_spec_warnings {
@@ -67,10 +88,10 @@
Class::MOP::load_class($app);
my $server;
if (my $e = $self->can('_plack_engine_name') ) {
- $server = Plack::Loader->load($self->$e, $self->_plack_loader_args);
+ $server = $self->load_engine($self->$e, $self->_plack_loader_args);
}
else {
- $server = Plack::Loader->auto($self->_plack_loader_args);
+ $server = $self->autoload_engine($self->_plack_loader_args);
}
$app->run($self->_application_args, $server);
}
Modified: Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst.pm 2010-05-24 15:44:09 UTC (rev 13310)
+++ Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst.pm 2010-05-24 15:44:11 UTC (rev 13311)
@@ -29,6 +29,7 @@
use Class::C3::Adopt::NEXT;
use List::MoreUtils qw/uniq/;
use attributes;
+use String::RewritePrefix;
use utf8;
use Carp qw/croak carp shortmess/;
use Try::Tiny;
@@ -2552,8 +2553,9 @@
unless ($engine) {
$engine = $class->engine_class;
}
- $engine = 'Catalyst::Engine::' . $engine
- unless $engine =~ /^Catalyst::Engine/;
+ else {
+ $engine = String::RewritePrefix->rewrite( { '' => 'Catalyst::Engine::', '+' => '' }, $engine );
+ }
$engine = 'Catalyst::Engine' if $engine eq 'Catalyst::Engine::HTTP';
@@ -2591,6 +2593,11 @@
);
}
+ if ($ENV{MOD_PERL}) {
+ # FIXME - Immutable
+ $class->meta->add_method(handler => sub { shift->handle_request(@_) });
+ }
+
$class->engine( $engine->new );
$class->psgi_app( $class->engine->build_psgi_app($class) );
}
More information about the Catalyst-commits
mailing list