From: Matt S Trout Date: Wed, 15 Oct 2008 19:17:30 +0000 (+0000) Subject: back out go() so we can ship a 5.7100 with other features and bugfixes X-Git-Tag: 5.7099_04~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=bfdaffa8cfd20d905dc451b05505d0ad8d476bea back out go() so we can ship a 5.7100 with other features and bugfixes --- diff --git a/Changes b/Changes index 5df5311..bad5081 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ # This file documents the revision history for Perl extension Catalyst. 5.7XXXXXX XXXX + - Back out go() since that feature's been pushed to 5.80 - Fix some Win32 test failures - Add pt translation of error message (wreis) - Make :Chained('../action') work (Florian Ragwitz) diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index a0f4e75..ccc996e 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -49,7 +49,6 @@ our $COUNT = 1; our $START = time; our $RECURSION = 1000; our $DETACH = "catalyst_detach\n"; -our $GO = "catalyst_go\n"; __PACKAGE__->mk_classdata($_) for qw/components arguments dispatcher engine log dispatcher_class @@ -328,20 +327,6 @@ When called with no arguments it escapes the processing chain entirely. sub detach { my $c = shift; $c->dispatcher->detach( $c, @_ ) } -=head2 $c->go( $action [, \@arguments ] ) - -=head2 $c->go( $class, $method, [, \@arguments ] ) - -Almost the same as C, but does a full dispatch, instead of just -calling the new C<$action> / C<$class-E$method>. This means that C, -C and the method you go to is called, just like a new request. - -C<$c-Estash> is kept unchanged. - -=cut - -sub go { my $c = shift; $c->dispatcher->go( $c, @_ ) } - =head2 $c->response =head2 $c->res @@ -1339,9 +1324,6 @@ sub execute { if ( !ref($error) and $error eq $DETACH ) { die $DETACH if($c->depth > 1); } - elsif ( !ref($error) and $error eq $GO ) { - die $GO if($c->depth > 0); - } else { unless ( ref $error ) { no warnings 'uninitialized'; diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 262301a..0f341de 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -165,34 +165,6 @@ sub _command2action { return $action, \@args; } -=head2 $self->go( $c, $command [, \@arguments ] ) - -Documented in L - -=cut - -sub go { - my $self = shift; - my ( $c, $command ) = @_; - my ( $action, $args ) = $self->_command2action(@_); - - unless ($action && defined $action->namespace) { - my $error = - qq/Couldn't go to command "$command": / - . qq/Invalid action or component./; - $c->error($error); - $c->log->debug($error) if $c->debug; - return 0; - } - - local $c->request->{arguments} = $args; - $c->namespace($action->namespace); - $c->action($action); - $self->dispatch($c); - - die $Catalyst::GO; -} - =head2 $self->forward( $c, $command [, \@arguments ] ) Documented in L diff --git a/t/live_component_controller_action_go.t b/t/live_component_controller_action_go.t deleted file mode 100644 index 544166d..0000000 --- a/t/live_component_controller_action_go.t +++ /dev/null @@ -1,254 +0,0 @@ -#!perl - -use strict; -use warnings; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -our $iters; - -BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } - -use Test::More tests => 50 * $iters; -use Catalyst::Test 'TestApp'; - -if ( $ENV{CAT_BENCHMARK} ) { - require Benchmark; - Benchmark::timethis( $iters, \&run_tests ); -} -else { - for ( 1 .. $iters ) { - run_tests(); - } -} - -sub run_tests { - { - # Test go to global private action - ok( my $response = request('http://localhost/action/go/global'), - 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content_type, 'text/plain', 'Response Content-Type' ); - is( $response->header('X-Catalyst-Action'), - 'action/go/global', 'Main Class Action' ); - } - - { - my @expected = qw[ - TestApp::Controller::Action::Go->one - TestApp::Controller::Action::Go->two - TestApp::Controller::Action::Go->three - TestApp::Controller::Action::Go->four - TestApp::Controller::Action::Go->five - TestApp::View::Dump::Request->process - TestApp->end - ]; - - @expected = map { /Action/ ? (_begin($_), $_) : ($_) } @expected; - my $expected = join( ", ", @expected ); - - # Test go to chain of actions. - ok( my $response = request('http://localhost/action/go/one'), - 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content_type, 'text/plain', 'Response Content-Type' ); - is( $response->header('X-Catalyst-Action'), - 'action/go/one', 'Test Action' ); - is( - $response->header('X-Test-Class'), - 'TestApp::Controller::Action::Go', - 'Test Class' - ); - is( $response->header('X-Catalyst-Executed'), - $expected, 'Executed actions' ); - like( - $response->content, - qr/^bless\( .* 'Catalyst::Request' \)$/s, - 'Content is a serialized Catalyst::Request' - ); - } - - { - my @expected = qw[ - TestApp::Controller::Action::Go->go_die - TestApp::Controller::Action::Go->args - TestApp->end - ]; - - @expected = map { /Action/ ? (_begin($_), $_) : ($_) } @expected; - my $expected = join( ", ", @expected ); - - ok( my $response = request('http://localhost/action/go/go_die'), - 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content_type, 'text/plain', 'Response Content-Type' ); - is( $response->header('X-Catalyst-Action'), - 'action/go/go_die', 'Test Action' - ); - is( - $response->header('X-Test-Class'), - 'TestApp::Controller::Action::Go', - 'Test Class' - ); - is( $response->header('X-Catalyst-Executed'), - $expected, 'Executed actions' ); - is( $response->content, $Catalyst::GO, "Go died as expected" ); - } - - { - ok( - my $response = - request('http://localhost/action/go/with_args/old'), - 'Request with args' - ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'old' ); - } - - { - ok( - my $response = request( - 'http://localhost/action/go/with_method_and_args/new'), - 'Request with args and method' - ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'new' ); - } - - # test go with embedded args - { - ok( - my $response = - request('http://localhost/action/go/args_embed_relative'), - 'Request' - ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'ok' ); - } - - { - ok( - my $response = - request('http://localhost/action/go/args_embed_absolute'), - 'Request' - ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'ok' ); - } - { - my @expected = qw[ - TestApp::Controller::Action::TestRelative->relative_go - TestApp::Controller::Action::Go->one - TestApp::Controller::Action::Go->two - TestApp::Controller::Action::Go->three - TestApp::Controller::Action::Go->four - TestApp::Controller::Action::Go->five - TestApp::View::Dump::Request->process - TestApp->end - ]; - - @expected = map { /Action/ ? (_begin($_), $_) : ($_) } @expected; - my $expected = join( ", ", @expected ); - - # Test go to chain of actions. - ok( my $response = request('http://localhost/action/relative/relative_go'), - 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content_type, 'text/plain', 'Response Content-Type' ); - is( $response->header('X-Catalyst-Action'), - 'action/relative/relative_go', 'Test Action' ); - is( - $response->header('X-Test-Class'), - 'TestApp::Controller::Action::Go', - 'Test Class' - ); - is( $response->header('X-Catalyst-Executed'), - $expected, 'Executed actions' ); - like( - $response->content, - qr/^bless\( .* 'Catalyst::Request' \)$/s, - 'Content is a serialized Catalyst::Request' - ); - } - { - my @expected = qw[ - TestApp::Controller::Action::TestRelative->relative_go_two - TestApp::Controller::Action::Go->one - TestApp::Controller::Action::Go->two - TestApp::Controller::Action::Go->three - TestApp::Controller::Action::Go->four - TestApp::Controller::Action::Go->five - TestApp::View::Dump::Request->process - TestApp->end - ]; - - @expected = map { /Action/ ? (_begin($_), $_) : ($_) } @expected; - my $expected = join( ", ", @expected ); - - # Test go to chain of actions. - ok( - my $response = - request('http://localhost/action/relative/relative_go_two'), - 'Request' - ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content_type, 'text/plain', 'Response Content-Type' ); - is( - $response->header('X-Catalyst-Action'), - 'action/relative/relative_go_two', - 'Test Action' - ); - is( - $response->header('X-Test-Class'), - 'TestApp::Controller::Action::Go', - 'Test Class' - ); - is( $response->header('X-Catalyst-Executed'), - $expected, 'Executed actions' ); - like( - $response->content, - qr/^bless\( .* 'Catalyst::Request' \)$/s, - 'Content is a serialized Catalyst::Request' - ); - } - - # test class go -- MUST FAIL! - { - ok( - my $response = request( - 'http://localhost/action/go/class_go_test_action'), - 'Request' - ); - ok( !$response->is_success, 'Response Fails' ); - is( $response->content, q(FATAL ERROR: Couldn't go to command "TestApp": Invalid action or component.), 'Error message' ); - } - - { - my @expected = qw[ - TestApp::Controller::Action::Go->begin - TestApp::Controller::Action::Go->go_chained - TestApp::Controller::Action::Chained->begin - TestApp::Controller::Action::Chained->foo - TestApp::Controller::Action::Chained::Foo->spoon - TestApp::Controller::Action::Chained->end - ]; - - my $expected = join( ", ", @expected ); - - ok( my $response = request('http://localhost/action/go/go_chained'), 'go to chained + subcontroller endpoint' ); - is( $response->header('X-Catalyst-Executed'), - $expected, 'Executed actions' ); - is( $response->content, '; 1', 'Content OK' ); - } - -} - - - -sub _begin { - local $_ = shift; - s/->(.*)$/->begin/; - return $_; -} -