X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=1c7d830741343630b1f916d841488d36363b44d8;hp=17605d40bd5eb83df992d23a49cd62f168f0d335;hb=dd5b1dc47018c241cafda7f2b565d6a39257a1bf;hpb=409d48fb495802db8eb6e02a927dd2915d8643b4 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 17605d4..1c7d830 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -35,11 +35,13 @@ use utf8; use Carp qw/croak carp shortmess/; use Try::Tiny; use Safe::Isa; +use Moose::Util 'find_meta'; use Plack::Middleware::Conditional; use Plack::Middleware::ReverseProxy; use Plack::Middleware::IIS6ScriptNameFix; use Plack::Middleware::IIS7KeepAliveFix; use Plack::Middleware::LighttpdScriptNameFix; +use Class::Load 'load_class'; BEGIN { require 5.008003; } @@ -113,7 +115,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90030'; +our $VERSION = '5.90042'; sub import { my ( $class, @arguments ) = @_; @@ -322,7 +324,18 @@ cookies, HTTP headers, etc.). See L. =head2 $c->forward( $class, $method, [, \@arguments ] ) -Forwards processing to another action, by its private name. If you give a +This is one way of calling another action (method) in the same or +a different controller. You can also use C<< $self->my_method($c, @args) >> +in the same controller or C<< $c->controller('MyController')->my_method($c, @args) >> +in a different controller. +The main difference is that 'forward' uses some of the Catalyst request +cycle overhead, including debugging, which may be useful to you. On the +other hand, there are some complications to using 'forward', restrictions +on values returned from 'forward', and it may not handle errors as you prefer. +Whether you use 'forward' or not is up to you; it is not considered superior to +the other ways to call a method. + +'forward' calls another action, by its private name. If you give a class name but no method, C is called. You may also optionally pass arguments in an arrayref. The action will receive the arguments in C<@_> and C<< $c->req->args >>. Upon returning from the function, @@ -1828,7 +1841,7 @@ sub finalize { $c->log_response; if ($c->use_stats) { - my $elapsed = sprintf '%f', $c->stats->elapsed; + my $elapsed = $c->stats->elapsed; my $av = $elapsed == 0 ? '??' : sprintf '%.3f', 1 / $elapsed; $c->log->info( "Request took ${elapsed}s ($av/s)\n" . $c->stats->report . "\n" ); @@ -2461,7 +2474,7 @@ sub run { sub _make_immutable_if_needed { my $class = shift; - my $meta = Class::MOP::get_metaclass_by_name($class); + my $meta = find_meta($class); my $isa_ca = $class->isa('Class::Accessor::Fast') || $class->isa('Class::Accessor'); if ( $meta->is_immutable @@ -2652,7 +2665,7 @@ sub setup_dispatcher { $dispatcher = $class->dispatcher_class; } - Class::MOP::load_class($dispatcher); + load_class($dispatcher); # dispatcher instance $class->dispatcher( $dispatcher->new ); @@ -2702,7 +2715,7 @@ sub setup_engine { # Don't really setup_engine -- see _setup_psgi_app for explanation. return if $class->loading_psgi_file; - Class::MOP::load_class($engine); + load_class($engine); if ($ENV{MOD_PERL}) { my $apache = $class->engine_loader->auto; @@ -2966,7 +2979,7 @@ the plugin name does not begin with C. my ( $proto, $plugin, $instant ) = @_; my $class = ref $proto || $proto; - Class::MOP::load_class( $plugin ); + load_class( $plugin ); $class->log->warn( "$plugin inherits from 'Catalyst::Component' - this is deprecated and will not work in 5.81" ) if $plugin->isa( 'Catalyst::Component' ); my $plugin_meta = Moose::Meta::Class->create($plugin); @@ -3001,7 +3014,7 @@ the plugin name does not begin with C. () } : $_ } @$plugins ]; - unshift @$plugins, $class->_default_plugins; + push @$plugins, $class->_default_plugins; $plugins = Data::OptList::mkopt($plugins || []); my @plugins = map { @@ -3014,7 +3027,7 @@ the plugin name does not begin with C. } @{ $plugins }; for my $plugin ( reverse @plugins ) { - Class::MOP::load_class($plugin->[0], $plugin->[1]); + load_class($plugin->[0], $plugin->[1]); my $meta = find_meta($plugin->[0]); next if $meta && $meta->isa('Moose::Meta::Role'); @@ -3193,7 +3206,7 @@ is having paths rewritten into it (e.g. as a .cgi/fcgi in a public_html director at other URIs than that which the app is 'normally' based at with C), the resolution of C<< $c->request->base >> will be incorrect. -=back +=back =item * @@ -3203,9 +3216,9 @@ C - See L. C - See L -=back +=item * -=item abort_chain_on_error_fix => 1 +C When there is an error in an action chain, the default behavior is to continue processing the remaining actions and then catch the error upon chain end. This @@ -3214,8 +3227,14 @@ you have this issue, setting this config value to true will promptly exit a chain when there is an error raised in any action (thus terminating the chain early.) +use like: + + __PACKAGE__->config(abort_chain_on_error_fix => 1); + In the future this might become the default behavior. +=back + =head1 INTERNAL ACTIONS Catalyst uses internal actions like C<_DISPATCH>, C<_BEGIN>, C<_AUTO>,