X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=7ca4f99649b46666f5859d90f707e1e3e409b60f;hb=54642e5a9d2365d9765360614cd753d7ca1df7aa;hp=ae606613ea3279d0273f8942e7f6d75efe1191d2;hpb=448e5011e539a42791c6822a3473fb627ce6af41;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index ae60661..7ca4f99 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -6,6 +6,7 @@ extends 'Catalyst::Component'; use Moose::Util qw/find_meta/; use bytes; use B::Hooks::EndOfScope (); +use Catalyst::Context; use Catalyst::Exception; use Catalyst::Exception::Detach; use Catalyst::Exception::Go; @@ -34,15 +35,13 @@ use Carp qw/croak carp shortmess/; BEGIN { require 5.008004; } -has stack => (is => 'ro', default => sub { [] }); -has stash => (is => 'rw', default => sub { {} }); -has state => (is => 'rw', default => 0); -has stats => (is => 'rw'); -has action => (is => 'rw'); -has counter => (is => 'rw', default => sub { {} }); -has request => (is => 'rw', default => sub { $_[0]->request_class->new({}) }, required => 1, lazy => 1); -has response => (is => 'rw', default => sub { $_[0]->response_class->new({}) }, required => 1, lazy => 1); -has namespace => (is => 'rw'); +has 'context' => ( + isa => 'Catalyst::Context', + is => 'rw', + handles => [ + qw/ action counter namespace request response stack stash state stats /, + ], +); sub depth { scalar @{ shift->stack || [] }; } sub comp { shift->component(@_) } @@ -804,7 +803,7 @@ If Catalyst can't find a component by name, it will fallback to regex matching by default. To disable this behaviour set disable_component_resolution_regex_fallback to a true value. - __PACKAGE__->config( { disable_component_resolution_regex_fallback => 1 } ); + __PACKAGE__->config( disable_component_resolution_regex_fallback => 1 ); =cut @@ -1629,12 +1628,13 @@ sub _stats_start_execute { # is this a root-level call or a forwarded call? if ( $callsub =~ /forward$/ ) { + my $parent = $c->stack->[-1]; # forward, locate the caller - if ( my $parent = $c->stack->[-1] ) { + if ( exists $c->counter->{"$parent"} ) { $c->stats->profile( begin => $action, - parent => "$parent" . ($c->counter->{"$parent"} || 0), + parent => "$parent" . $c->counter->{"$parent"}, uid => $uid, ); } @@ -1885,7 +1885,8 @@ sub prepare { # into the application. $class->context_class( ref $class || $class ) unless $class->context_class; - my $c = $class->context_class->new({}); + my $context = Catalyst::Context->new(); + my $c = $class->context_class->new({ context => $context }); # For on-demand data $c->request->_context($c); @@ -2665,7 +2666,74 @@ sub version { return $Catalyst::VERSION } =head1 CONFIGURATION - # TODO include things like 'current_view' and maybe reiterate things like 'name' too +There are a number of 'base' config variables which can be set: + +=over + +=item * + +C - Makes private paths case sensitive. See L. + +=item * + +C - The default model picked if you say C<< $c->model >>. See Lmodel($name)>. + +=item * + +C - The default view to be rendered or returned when C<< $c->view >>. See Lview($name)>. +is called. + +=item * + +C - Turns +off the deprecated component resolution functionality so +that if any of the component methods (e.g. C<< $c->controller('Foo') >>) +are called then regex search will not be attempted on string values and +instead C will be returned. + +=item * + +C - The application home directory. In an uninstalled application, +this is the top level application directory. In an installed application, +this will be the directory containing C<< MyApp.pm >>. + +=item * + +C - See L + +=item * + +C - The name of the application in debug messages and the debug and +welcome screens + +=item * + +C - The request body (for example file uploads) will not be parsed +until it is accessed. This allows you to (for example) check authentication (and reject +the upload) before actually recieving all the data. See L + +=item * + +C - The root directory for templates. Usually this is just a +subdirectory of the home directory, but you can set it to change the +templates to a different directory. + +=item * + +C - Array reference passed to Module::Pluggable to for additional +namespaces from which components will be loaded (and constructed and stored in +C<< $c->components >>). + +=item * + +C - If true, causes internal actions such as C<< _DISPATCH >> +to be shown in hit debug tables in the test server. + +=item * + +C - See L. + +=back =head1 INTERNAL ACTIONS