X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=2331ae6477f299ae9fc7b9cb94ef07c77b0dd387;hb=264bac8c94a84d7dbac9912946d1a639fa37d1cd;hp=d7b53ae16cec4184939372519f458f0b31ca34fb;hpb=8641855930b874893d1a898a552799f999a2084a;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index d7b53ae..2331ae6 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -12,13 +12,13 @@ use Catalyst::Utils; use Catalyst::Controller; use Devel::InnerPackage (); use File::stat; -use Module::Pluggable::Object; +use Module::Pluggable::Object (); use NEXT; -use Text::SimpleTable; -use Path::Class::Dir; -use Path::Class::File; +use Text::SimpleTable (); +use Path::Class::Dir (); +use Path::Class::File (); use Time::HiRes qw/gettimeofday tv_interval/; -use URI; +use URI (); use Scalar::Util qw/weaken blessed/; use Tree::Simple qw/use_weak_refs/; use Tree::Simple::Visitor::FindByUID; @@ -61,7 +61,7 @@ __PACKAGE__->response_class('Catalyst::Response'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.70_03'; +our $VERSION = '5.7001'; sub import { my ( $class, @arguments ) = @_; @@ -293,9 +293,13 @@ sub forward { my $c = shift; $c->dispatcher->forward( $c, @_ ) } =head2 $c->detach( $class, $method, [, \@arguments ] ) +=head2 $c->detach() + The same as C, but doesn't return to the previous action when processing is finished. +When called with no arguments it escapes the processing chain entirely. + =cut sub detach { my $c = shift; $c->dispatcher->detach( $c, @_ ) } @@ -860,8 +864,8 @@ EOF =head2 $c->uri_for( $path, @args?, \%query_values? ) -Merges path with C<$c-Erequest-Ebase> for absolute URIs and with -C<$c-Enamespace> for relative URIs, then returns a normalized L +Merges path with C<< $c->request->base >> for absolute URIs and with +C<< $c->namespace >> for relative URIs, then returns a normalized L object. If any args are passed, they are added at the end of the path. If the last argument to C is a hash reference, it is assumed to contain GET parameter key/value pairs, which will be appended to the URI @@ -869,7 +873,7 @@ in standard fashion. Instead of C<$path>, you can also optionally pass a C<$action> object which will be resolved to a path using -C<$c-Edispatcher-Euri_for_action>; if the first element of +C<< $c->dispatcher->uri_for_action >>; if the first element of C<@args> is an arrayref it is treated as a list of captures to be passed to C. @@ -889,6 +893,7 @@ sub uri_for { : [] ); $path = $c->dispatcher->uri_for_action($path, $captures); return undef unless defined($path); + $path = '/' if $path eq ''; } # massage namespace, empty if absolute path @@ -902,11 +907,10 @@ sub uri_for { ( scalar @args && ref $args[$#args] eq 'HASH' ? pop @args : {} ); for my $value ( values %$params ) { - my $isa_ref = ref $value; - if( $isa_ref and $isa_ref ne 'ARRAY' ) { - croak( "Non-array reference ($isa_ref) passed to uri_for()" ); + for ( ref $value eq 'ARRAY' ? @$value : $value ) { + $_ = "$_"; + utf8::encode( $_ ); } - utf8::encode( $_ ) for grep { defined } $isa_ref ? @$value : $value; }; # join args with '/', or a blank string @@ -1129,7 +1133,7 @@ sub execute { if ( $c->depth >= $RECURSION ) { my $action = "$code"; - $action = "/$action" unless $action =~ /\-\>/; + $action = "/$action" unless $action =~ /->/; my $error = qq/Deep recursion detected calling "$action"/; $c->log->error($error); $c->error($error); @@ -1148,9 +1152,10 @@ sub execute { my $last = pop( @{ $c->stack } ); if ( my $error = $@ ) { - if ( $error eq $DETACH ) { die $DETACH if $c->depth > 1 } + if ( !ref($error) and $error eq $DETACH ) { die $DETACH if $c->depth > 1 } else { unless ( ref $error ) { + no warnings 'uninitialized'; chomp $error; my $class = $last->class; my $name = $last->name; @@ -1794,7 +1799,7 @@ sub setup_components { ); for my $component ( sort { length $a <=> length $b } $locator->plugins ) { - Catalyst::Utils::ensure_class_loaded( $component ); + Catalyst::Utils::ensure_class_loaded( $component, { ignore_loaded => 1 } ); my $module = $class->setup_component( $component ); my %modules = (