X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=c6eed9efcb7f9362eafcc8c34fae686927ffa90f;hb=6d12f1d498c8f04610d1b222ae5f9a7301c3c312;hp=8f94316cd2624f4711425925e6fd3bfdba72cb6a;hpb=a0eca83861c733269dbafbaafbcc3ca0b0101e2b;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 8f94316..c6eed9e 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -80,19 +80,17 @@ sub forward { my $c = shift; my $command = shift; - # Get the calling class - my $caller = ( caller(0) )[0]; - if ( $caller->isa('Catalyst') ) { - if ( ( caller(2) )[3] =~ /detach$/ ) { $caller = caller(3) } - elsif ( ( caller(0) )[3] =~ /forward$/ ) { $caller = caller(1) } - } - unless ($command) { $c->log->debug('Nothing to forward to') if $c->debug; return 0; } - my $arguments = ( ref( $_[-1] ) eq 'ARRAY' ) ? pop(@_) : $c->req->args; + my $local_args = 0; + my $arguments = $c->req->args; + if ( ref( $_[-1] ) eq 'ARRAY' ) { + $arguments = pop(@_); + $local_args = 1; + } my $result; @@ -100,11 +98,8 @@ sub forward { my $command_copy = $command; unless ( $command_copy =~ s/^\/// ) { - my $prefix = - Catalyst::Utils::class2prefix( $caller, - $c->config->{case_sensitive} ) - || ''; - $command_copy = "${prefix}/${command}"; + my $namespace = $c->stack->[-1]->namespace; + $command_copy = "${namespace}/${command}"; } unless ( $command_copy =~ /\// ) { @@ -116,7 +111,8 @@ sub forward { my $tail = $2; $result = $c->get_action( $tail, $1 ); if ($result) { - $command = $tail; + $local_args = 1; + $command = $tail; push( @{$arguments}, @extra_args ); last DESCEND; } @@ -145,7 +141,9 @@ qq/Couldn't forward to command "$command". Invalid action or component./; code => $code, reverse => "$class->$method", class => $class, - namespace => $class, + namespace => Catalyst::Utils::class2prefix( + $class, $c->config->{case_sensitive} + ), } ); $result = $action; @@ -162,9 +160,11 @@ qq/Couldn't forward to command "$command". Invalid action or component./; } - local $c->request->{arguments} = [ @{$arguments} ]; - - $result->execute($c); + if ($local_args) { + local $c->request->{arguments} = [ @{$arguments} ]; + $result->execute($c); + } + else { $result->execute($c) } return $c->state; } @@ -381,9 +381,9 @@ sub setup_actions { return unless $c->debug; my $privates = Text::SimpleTable->new( - [ 24, 'Private' ], - [ 23, 'Class' ], - [ 23, 'Method' ] + [ 20, 'Private' ], + [ 38, 'Class' ], + [ 12, 'Method' ] ); my $has_private = 0;