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;
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/;
+
+sub dispatcher_class {
+ return $_[0]->_dispatcher_class(@_[1..$#_]) || 'Catalyst::Dispatcher';
+}
+
+sub engine_class {
+ return $_[0]->_engine_class(@_[1..$#_]) || 'Catalyst::Engine::CGI';
+}
+
+sub context_class {
+ return $_[0]->_context_class(@_[1..$#_]) || ref $_[0] || $_[0];
+}
+
+sub request_class {
+ return $_[0]->_request_class(@_[1..$#_]) || 'Catalyst::Request';
+}
+
+sub response_class {
+ return $_[0]->_response_class(@_[1..$#_]) || 'Catalyst::Response';
+}
our $VERSION = '5.49_03';
$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 } );
}
=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 )
sub prepare {
my ( $class, @arguments ) = @_;
- my $c = bless {
+ my $c = $class->context_class->new({
counter => {},
depth => 0,
- request => Catalyst::Request->new(
+ request => $class->request_class->new(
{
arguments => [],
body_parameters => {},
uploads => {}
}
),
- response => Catalyst::Response->new(
+ response => $class->response_class->new(
{
body => '',
cookies => {},
),
stash => {},
state => 0
- }, $class;
+ });
# For on-demand data
$c->request->{_context} = $c;
}
unless ($dispatcher) {
- $dispatcher = 'Catalyst::Dispatcher';
+ $dispatcher = $class->dispatcher_class;
}
$dispatcher->require;
}
unless ($engine) {
- $engine = 'Catalyst::Engine::CGI';
+ $engine = $class->engine_class;
}
$engine->require;
Autrijus Tang
+Brian Cassidy
+
Christian Hansen
Christopher Hicks