From: Yuval Kogman Date: Fri, 21 Apr 2006 21:11:17 +0000 (+0000) Subject: new incarnation of the continuation plugin X-Git-Tag: 5.7099_04~622 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=3d0d6d21a332320044e06386cccc67a9302b8c84 new incarnation of the continuation plugin --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 1026625..b655be3 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1198,6 +1198,23 @@ sub execute { return $c->state; } +=head2 $c->_localize_fields( sub { }, \%keys ); + +=cut + +sub _localize_fields { + my ( $c, $localized, $code ) = ( @_ ); + + my $request = delete $localized->{request} || {}; + my $response = delete $localized->{response} || {}; + + local @{ $c }{ keys %$localized } = values %$localized; + local @{ $c->request }{ keys %$request } = values %$request; + local @{ $c->response }{ keys %$response } = values %$response; + + $code->(); +} + =head2 $c->finalize Finalizes the request. diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 391fefc..e330047 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -286,12 +286,23 @@ returns a named action from a given namespace. sub get_action { my ( $self, $name, $namespace ) = @_; return unless $name; - $namespace ||= ''; - $namespace = '' if $namespace eq '/'; + + $namespace = join("/", grep { length } split '/', $namespace || "" ); return $self->action_hash->{"$namespace/$name"}; } +=head2 $self->get_action_by_path( $path ); + +returns the named action by it's full path. + +=cut + +sub get_action_by_path { + my ( $self, $path ) = @_; + $self->action_hash->{$path}; +} + =head2 $self->get_actions( $c, $action, $namespace ) =cut @@ -299,8 +310,8 @@ sub get_action { sub get_actions { my ( $self, $c, $action, $namespace ) = @_; return [] unless $action; - $namespace ||= ''; - $namespace = '' if $namespace eq '/'; + + $namespace = join("/", grep { length } split '/', $namespace || "" ); my @match = $self->get_containers($namespace);