X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=9fee7bea2b22b0686d5cd6f0981d9a14ffcc5dcb;hp=fd2c65be03bc25ab971f648cddf6f999746ade78;hb=3cec521ae07b2d779f88adab532f791ad42c8676;hpb=bcd1002b0ed8c8fe6dbfdc94417be0fe8cd52832 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index fd2c65b..9fee7be 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -16,11 +16,14 @@ use Path::Class; use Time::HiRes qw/gettimeofday tv_interval/; use URI; use Scalar::Util qw/weaken/; +use attributes; __PACKAGE__->mk_accessors( qw/counter depth request response state action namespace/ ); +attributes->import( __PACKAGE__, \&namespace, 'lvalue' ); + # Laziness++ *comp = \&component; *req = \&request; @@ -41,7 +44,13 @@ require Module::Pluggable::Fast; our $CATALYST_SCRIPT_GEN = 10; __PACKAGE__->mk_classdata($_) - for qw/components arguments dispatcher engine log/; + for qw/components arguments dispatcher engine log dispatcher_class + engine_class context_class request_class response_class/; + +__PACKAGE__->dispatcher_class('Catalyst::Dispatcher'); +__PACKAGE__->engine_class('Catalyst::Engine::CGI'); +__PACKAGE__->request_class('Catalyst::Request'); +__PACKAGE__->response_class('Catalyst::Response'); our $VERSION = '5.49_03'; @@ -412,8 +421,11 @@ sub setup { $class->setup_components; if ( $class->debug ) { - my $t = Text::SimpleTable->new(76); - $t->row($_) for sort keys %{ $class->components }; + my $t = Text::SimpleTable->new( [ 65, 'Class' ], [ 8, 'Type' ] ); + for my $comp ( sort keys %{ $class->components } ) { + my $type = ref $class->components->{$comp} ? 'instance' : 'class'; + $t->row( $comp, $type ); + } $class->log->debug( "Loaded components:\n" . $t->draw ) if ( keys %{ $class->components } ); } @@ -988,7 +1000,7 @@ Get an action in a given namespace. =cut -sub get_action { my $c = shift; $c->dispatcher->get_action( @_ ) } +sub get_action { my $c = shift; $c->dispatcher->get_action(@_) } =item $c->get_actions( $action, $namespace ) @@ -1055,33 +1067,36 @@ into a Catalyst context . sub prepare { my ( $class, @arguments ) = @_; - my $c = bless { - counter => {}, - depth => 0, - request => Catalyst::Request->new( - { - arguments => [], - body_parameters => {}, - cookies => {}, - headers => HTTP::Headers->new, - parameters => {}, - query_parameters => {}, - secure => 0, - snippets => [], - uploads => {} - } - ), - response => Catalyst::Response->new( - { - body => '', - cookies => {}, - headers => HTTP::Headers->new(), - status => 200 - } - ), - stash => {}, - state => 0 - }, $class; + $class->context_class( ref $class || $class ) unless $class->context_class; + my $c = $class->context_class->new( + { + counter => {}, + depth => 0, + request => $class->request_class->new( + { + arguments => [], + body_parameters => {}, + cookies => {}, + headers => HTTP::Headers->new, + parameters => {}, + query_parameters => {}, + secure => 0, + snippets => [], + uploads => {} + } + ), + response => $class->response_class->new( + { + body => '', + cookies => {}, + headers => HTTP::Headers->new(), + status => 200 + } + ), + stash => {}, + state => 0 + } + ); # For on-demand data $c->request->{_context} = $c; @@ -1420,7 +1435,7 @@ sub setup_dispatcher { } unless ($dispatcher) { - $dispatcher = 'Catalyst::Dispatcher'; + $dispatcher = $class->dispatcher_class; } $dispatcher->require; @@ -1509,7 +1524,7 @@ sub setup_engine { } unless ($engine) { - $engine = 'Catalyst::Engine::CGI'; + $engine = $class->engine_class; } $engine->require; @@ -1781,6 +1796,8 @@ Arthur Bergman Autrijus Tang +Brian Cassidy + Christian Hansen Christopher Hicks