[Catalyst-commits] r7575 - in
Catalyst-Runtime/5.80/branches/context_go: lib lib/Catalyst
t/lib/TestApp/Controller/Action
batman at dev.catalyst.perl.org
batman at dev.catalyst.perl.org
Sun Apr 6 15:51:37 BST 2008
Author: batman
Date: 2008-04-06 15:51:36 +0100 (Sun, 06 Apr 2008)
New Revision: 7575
Modified:
Catalyst-Runtime/5.80/branches/context_go/lib/Catalyst.pm
Catalyst-Runtime/5.80/branches/context_go/lib/Catalyst/Dispatcher.pm
Catalyst-Runtime/5.80/branches/context_go/t/lib/TestApp/Controller/Action/Go.pm
Log:
go() does not eval anymore. Rewrote go() POD. Fixed bug where end was called twice. Some other tests fail though...
Modified: Catalyst-Runtime/5.80/branches/context_go/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/context_go/lib/Catalyst/Dispatcher.pm 2008-04-06 10:23:16 UTC (rev 7574)
+++ Catalyst-Runtime/5.80/branches/context_go/lib/Catalyst/Dispatcher.pm 2008-04-06 14:51:36 UTC (rev 7575)
@@ -127,19 +127,16 @@
}
}
-=head2 $self->_command2action( $c, $command [, \@arguments ] )
+# $self->_command2action( $c, $command [, \@arguments ] )
+# Search for an action, from the command and returns C<($action, $args)> on
+# success. Returns C<(0)> on error.
-Search for an action, from the command and returns C<($c, $action)> on
-success. Returns C<($c, 0)> on error.
-
-=cut
-
sub _command2action {
my ( $self, $c, $command, @extra_params ) = @_;
unless ($command) {
$c->log->debug('Nothing to go to') if $c->debug;
- return $c, 0;
+ return 0;
}
my @args;
@@ -165,18 +162,7 @@
$action = $self->_invoke_as_component( $c, $command, $method );
}
- unless ($action) {
- 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 $c, 0;
- }
-
- #push @$args, @_;
-
- return $c, $action, \@args;
+ return $action, \@args;
}
=head2 $self->go( $c, $command [, \@arguments ] )
@@ -187,16 +173,23 @@
sub go {
my $self = shift;
- my ( $c, $action, $args ) = $self->_command2action(@_);
+ my ( $c, $command ) = @_;
+ my ( $action, $args ) = $self->_command2action(@_);
- return 0 unless($action);
+ unless ($action) {
+ 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);
- eval { $self->dispatch($c) };
+ $self->dispatch($c);
- die $@ if($@);
die $Catalyst::GO;
}
@@ -208,9 +201,17 @@
sub forward {
my $self = shift;
- my ( $c, $action, $args ) = $self->_command2action(@_);
+ my ( $c, $command ) = @_;
+ my ( $action, $args ) = $self->_command2action(@_);
- return 0 unless($action);
+ unless ($action) {
+ my $error =
+ qq/Couldn't forward 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;
$action->dispatch( $c );
Modified: Catalyst-Runtime/5.80/branches/context_go/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/context_go/lib/Catalyst.pm 2008-04-06 10:23:16 UTC (rev 7574)
+++ Catalyst-Runtime/5.80/branches/context_go/lib/Catalyst.pm 2008-04-06 14:51:36 UTC (rev 7575)
@@ -330,11 +330,16 @@
sub detach { my $c = shift; $c->dispatcher->detach( $c, @_ ) }
-=head2 $c->go()
+=head2 $c->go( $action [, \@arguments ] )
-Acts like an internal redirect, in you Catalyst app: Calls begin(), auto(),
-the new action and end() in the class you go() to.
+=head2 $c->go( $class, $method, [, \@arguments ] )
+Almost the same as C<detach>, but does a full dispatch, instead of just
+calling the new C<$action> / C<$class-E<gt>$method>. This means that C<begin>,
+C<auto> and the method you go to is called, just like a new request.
+
+C<$c-E<gt>stash> is kept unchanged.
+
=cut
sub go { my $c = shift; $c->dispatcher->go( $c, @_ ) }
@@ -1236,8 +1241,12 @@
my $last = pop( @{ $c->stack } );
if ( my $error = $@ ) {
- 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 > 1 }
+ 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';
Modified: Catalyst-Runtime/5.80/branches/context_go/t/lib/TestApp/Controller/Action/Go.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/context_go/t/lib/TestApp/Controller/Action/Go.pm 2008-04-06 10:23:16 UTC (rev 7574)
+++ Catalyst-Runtime/5.80/branches/context_go/t/lib/TestApp/Controller/Action/Go.pm 2008-04-06 14:51:36 UTC (rev 7575)
@@ -58,6 +58,7 @@
my ( $self, $c, $val ) = @_;
eval { $c->go( 'args', [qq/new/] ) };
$c->res->body( $@ ? $@ : "go() did not die" );
+ die $Catalyst::GO;
}
sub args_embed_relative : Local {
More information about the Catalyst-commits
mailing list