From: Matt S Trout Date: Thu, 10 Nov 2005 01:48:40 +0000 (+0000) Subject: - Added $c->stack X-Git-Tag: 5.7099_04~978 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=28591cd7cf934c9aa0a692e89ee9f40338814020 - Added $c->stack --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 3d2f825..7d6e4fa 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -19,11 +19,14 @@ use Scalar::Util qw/weaken/; use attributes; __PACKAGE__->mk_accessors( - qw/counter depth request response state action namespace/ + qw/counter request response state action stack namespace/ ); attributes->import( __PACKAGE__, \&namespace, 'lvalue' ); +sub depth { scalar @{shift->stack||[]}; } +#sub namespace { my $a = shift->stack->[-1]; ($a ? $a->namespace : ''); } + # Laziness++ *comp = \&component; *req = \&request; @@ -859,7 +862,7 @@ sub execute { $action = "-> $action" if $callsub =~ /forward$/; } - $c->{depth}++; + push(@{$c->stack}, $code); eval { if ( $c->debug ) { @@ -876,11 +879,11 @@ sub execute { $c->state( &$code( $class, $c, @{ $c->req->args } ) || 0 ); } }; - $c->{depth}--; + pop(@{$c->stack}); if ( my $error = $@ ) { - if ( $error eq $DETACH ) { die $DETACH if $c->{depth} > 1 } + if ( $error eq $DETACH ) { die $DETACH if $c->depth > 1 } else { unless ( ref $error ) { chomp $error; @@ -1083,7 +1086,7 @@ sub prepare { my $c = $class->context_class->new( { counter => {}, - depth => 0, + stack => [], request => $class->request_class->new( { arguments => [], diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index b9bc30f..34691a4 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -58,7 +58,7 @@ sub dispatch { my ( $self, $c ) = @_; if ( $c->action ) { - $c->forward( join( '/', '', $c->namespace, '_DISPATCH' ) ); + $c->forward( join( '/', '', $c->action->namespace, '_DISPATCH' ) ); } else {