From: Christian Hansen Date: Fri, 25 Mar 2005 19:13:03 +0000 (+0000) Subject: - removed C::E::Server X-Git-Tag: 5.7099_04~1683 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=d96e14c21fb544597f459aaaad969c34af7f2d1f - removed C::E::Server - Detect C::E::Server in Catalyst.pm, use C::E::H::Daemon instead - moved back C:E:LWP::Daemon to C::E::HTTP:Daemon - rename $ENV{CATALYST_REMOTE} with $ENV{CATALYST_SERVER} - updated helper script server.pl - prevent Catalyst->import from being called twice - added $class->import in C::Test --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 26047c3..328a358 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -146,6 +146,10 @@ sub import { push @{"$caller\::ISA"}, $self; } + if ( $caller->engine ) { + return; # Catalyst is allready initialized + } + unless ( $caller->log ) { $caller->log( Catalyst::Log->new ); } @@ -190,6 +194,13 @@ sub import { # Engine $engine = "Catalyst::Engine::$ENV{CATALYST_ENGINE}" if $ENV{CATALYST_ENGINE}; + + if ( $engine eq 'Catalyst::Engine::Server' ) { + $engine = 'Catalyst::Engine::HTTP::Daemon'; + $caller->log->warn( "Catalyst::Engine::Server is deprecated, " + . "using Catalyst::Engine::HTTP::Daemon." ); + } + $engine->require; die qq/Couldn't load engine "$engine", "$@"/ if $@; { diff --git a/lib/Catalyst/Engine/LWP/Daemon.pm b/lib/Catalyst/Engine/HTTP/Daemon.pm similarity index 83% rename from lib/Catalyst/Engine/LWP/Daemon.pm rename to lib/Catalyst/Engine/HTTP/Daemon.pm index 84b9c27..65129ee 100644 --- a/lib/Catalyst/Engine/LWP/Daemon.pm +++ b/lib/Catalyst/Engine/HTTP/Daemon.pm @@ -1,4 +1,4 @@ -package Catalyst::Engine::LWP::Daemon; +package Catalyst::Engine::HTTP::Daemon; use strict; use base 'Catalyst::Engine::LWP'; @@ -7,16 +7,16 @@ use IO::Socket qw(AF_INET); =head1 NAME -Catalyst::Engine::LWP::Daemon - Catalyst LWP Daemon Engine +Catalyst::Engine::HTTP::Daemon - Catalyst HTTP Daemon Engine =head1 SYNOPSIS -A script using the Catalyst::Engine::LWP::Daemon module might look like: +A script using the Catalyst::Engine::HTTP::Daemon module might look like: #!/usr/bin/perl -w BEGIN { - $ENV{CATALYST_ENGINE} = 'LWP::Daemon'; + $ENV{CATALYST_ENGINE} = 'HTTP::Daemon'; } use strict; @@ -45,7 +45,7 @@ sub run { my $class = shift; my $port = shift || 3000; - my $daemon = Catalyst::Engine::LWP::Daemon::Catalyst->new( + my $daemon = Catalyst::Engine::HTTP::Daemon::Catalyst->new( LocalPort => $port, ReuseAddr => 1 ); @@ -95,7 +95,7 @@ the same terms as Perl itself. =cut -package Catalyst::Engine::LWP::Daemon::Catalyst; +package Catalyst::Engine::HTTP::Daemon::Catalyst; use strict; use base 'HTTP::Daemon'; diff --git a/lib/Catalyst/Engine/LWP.pm b/lib/Catalyst/Engine/LWP.pm index 01580a0..ae24063 100644 --- a/lib/Catalyst/Engine/LWP.pm +++ b/lib/Catalyst/Engine/LWP.pm @@ -91,7 +91,7 @@ sub prepare_connection { sub prepare_cookies { my $c = shift; - if ( my $header = $c->lwp->request->header('Cookie') ) { + if ( my $header = $c->request->headers->header('Cookie') ) { $c->req->cookies( { CGI::Simple::Cookie->parse($header) } ); } } diff --git a/lib/Catalyst/Engine/Server.pm b/lib/Catalyst/Engine/Server.pm deleted file mode 100644 index 8db6d33..0000000 --- a/lib/Catalyst/Engine/Server.pm +++ /dev/null @@ -1,46 +0,0 @@ -package Catalyst::Engine::Server; - -use strict; -use base 'Catalyst::Engine::LWP::Daemon'; - -=head1 NAME - -Catalyst::Engine::Server - Catalyst Server Engine - -=head1 SYNOPSIS - -A script using the Catalyst::Engine::Server module might look like: - - #!/usr/bin/perl -w - - BEGIN { - $ENV{CATALYST_ENGINE} = 'Server'; - } - - use strict; - use lib '/path/to/MyApp/lib'; - use MyApp; - - MyApp->run; - -=head1 DESCRIPTION - -This is the Catalyst engine specialized for development and testing. - -=head1 SEE ALSO - -L, L. - -=head1 AUTHOR - -Sebastian Riedel, C -Christian Hansen, C - -=head1 COPYRIGHT - -This program is free software, you can redistribute it and/or modify it under -the same terms as Perl itself. - -=cut - -1; diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index 8c392cb..71efd7d 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -476,7 +476,7 @@ sub _mk_server { $self->mk_file( "$script\/server.pl", <<"EOF"); $Config{startperl} -w -BEGIN { \$ENV{CATALYST_ENGINE} = 'Server' } +BEGIN { \$ENV{CATALYST_ENGINE} = 'HTTP::Daemon' } use strict; use Getopt::Long; diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index 3de24ad..4ca73ee 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -20,7 +20,7 @@ Catalyst::Test - Test Catalyst applications get('index.html'); # Run tests against a remote server - CATALYST_REMOTE='http://localhost:3000/' prove -l lib/ t/ + CATALYST_SERVER='http://localhost:3000/' prove -l lib/ t/ # Tests with inline apps need to use Catalyst::Engine::Test package TestApp; @@ -67,17 +67,20 @@ sub import { my ( $get, $request ); - if ( $ENV{CATALYST_REMOTE} ) { + if ( $ENV{CATALYST_SERVER} ) { $request = sub { remote_request(@_) }; $get = sub { remote_request(@_)->content }; } else { $class->require; + unless ( $INC{'Test/Builder.pm'} ) { die qq/Couldn't load "$class", "$@"/ if $@; } + $class->import; + $request = sub { $class->run(@_) }; $get = sub { $class->run(@_)->content }; } @@ -93,7 +96,7 @@ sub remote_request { require LWP::UserAgent; - my $remote = URI->new( $ENV{CATALYST_REMOTE} ); + my $remote = URI->new( $ENV{CATALYST_SERVER} ); unless ( ref $request ) {