X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=c092d500bd1635508f4cfbd9aa3969a4ecf6f993;hb=4400b5efc1c3db0fe5657ab73f1628e1d7f1b02a;hp=8d84e858d5c3d9211b7d405c6fec89ab041130ae;hpb=1d4ea19dc484e729cef526db0f72927a9ba5d62b;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 8d84e85..c092d50 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -127,7 +127,9 @@ sub finalize { if ( my $location = $c->res->redirect ) { $c->log->debug(qq/Redirecting to "$location"/) if $c->debug; $c->res->headers->header( Location => $location ); + $c->res->headers->remove_content_headers; $c->res->status(302); + return $c->finalize_headers; } if ( !$c->res->output || $#{ $c->error } >= 0 ) { @@ -373,11 +375,13 @@ sub handler ($$) { for my $begin ( @{ $c->get_action( 'begin', $namespace ) } ) { $c->state( $c->execute( @{ $begin->[0] } ) ); } - for my $result ( @{ $c->get_action( $action, $default ) } ) { + for my $result ( @{ $c->get_action( $action, $default ) }[-1] ) + { $c->state( $c->execute( @{ $result->[0] } ) ); last unless $default; } - for my $end ( @{ $c->get_action( 'end', $namespace ) } ) { + for my $end ( reverse @{ $c->get_action( 'end', $namespace ) } ) + { $c->state( $c->execute( @{ $end->[0] } ) ); } } @@ -638,10 +642,10 @@ sub set_action { my %flags; for my $attr ( @{$attrs} ) { - if ( $attr =~ /^(Local|Relative)$/ ) { $flags{local}++ } - elsif ( $attr =~ /^(Global|Absolute)$/ ) { $flags{global}++ } - elsif ( $attr =~ /^Path\((.+)\)$/i ) { $flags{path} = $1 } - elsif ( $attr =~ /^Private$/i ) { $flags{private}++ } + if ( $attr =~ /^(Local|Relative)$/ ) { $flags{local}++ } + elsif ( $attr =~ /^(Global|Absolute)$/ ) { $flags{global}++ } + elsif ( $attr =~ /^Path\((.+)\)$/i ) { $flags{path} = $1 } + elsif ( $attr =~ /^Private$/i ) { $flags{private}++ } elsif ( $attr =~ /^(Regex|Regexp)\((.+)\)$/i ) { $flags{regex} = $2 } } @@ -733,10 +737,23 @@ sub setup_actions { my ( $code, $attrs ) = @{$action}; my $name = ''; no strict 'refs'; - for my $sym ( values %{ $comp . '::' } ) { - if ( *{$sym}{CODE} && *{$sym}{CODE} == $code ) { - $name = *{$sym}{NAME}; - $self->set_action( $name, $code, $comp, $attrs ); + my @cache = ( $comp, @{"$comp\::ISA"} ); + my %namespaces; + while ( my $namespace = shift @cache ) { + $namespaces{$namespace}++; + for my $isa ( @{"$comp\::ISA"} ) { + next if $namespaces{$isa}; + push @cache, $isa; + $namespaces{$isa}++; + } + } + for my $namespace ( keys %namespaces ) { + for my $sym ( values %{ $namespace . '::' } ) { + if ( *{$sym}{CODE} && *{$sym}{CODE} == $code ) { + $name = *{$sym}{NAME}; + $self->set_action( $name, $code, $comp, $attrs ); + last; + } } } } @@ -810,9 +827,9 @@ sub _prefix { sub _class2prefix { my $class = shift || ''; my $prefix; - if ($class =~ /^.*::([MVC]|Model|View|Controller)?::(.*)$/) { - $prefix = lc $2; - $prefix =~ s/\:\:/\//g; + if ( $class =~ /^.*::([MVC]|Model|View|Controller)?::(.*)$/ ) { + $prefix = lc $2; + $prefix =~ s/\:\:/\//g; } return $prefix; }