X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=70d6ac3bcc6140ae56784a1fa720fb85f735d225;hb=aba0841d12cbaa53592f6792ca4ff175070fd86a;hp=6dbd0a1fa80da0e9bbed411ce59c197000853629;hpb=4055796051cccaa2276eca36b8661e3f785f7be3;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 6dbd0a1..70d6ac3 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -51,20 +51,30 @@ has request => ( is => 'rw', default => sub { my $self = shift; - my %p = ( _log => $self->log ); - $p{_uploadtmp} = $self->_uploadtmp if $self->_has_uploadtmp; - $self->request_class->new(\%p); + $self->request_class->new($self->_build_request_constructor_args); }, lazy => 1, ); +sub _build_request_constructor_args { + my $self = shift; + my %p = ( _log => $self->log ); + $p{_uploadtmp} = $self->_uploadtmp if $self->_has_uploadtmp; + \%p; +} + has response => ( is => 'rw', default => sub { my $self = shift; - $self->response_class->new({ _log => $self->log }); + $self->response_class->new($self->_build_response_constructor_args); }, lazy => 1, ); +sub _build_response_constructor_args { + my $self = shift; + { _log => $self->log }; +} + has namespace => (is => 'rw'); sub depth { scalar @{ shift->stack || [] }; } @@ -101,7 +111,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90016'; +our $VERSION = '5.90017'; sub import { my ( $class, @arguments ) = @_; @@ -1010,11 +1020,20 @@ EOF if ( $class->debug and - my $comps = $class->container->get_all_components($class) + my $comps = $class->container->get_all_component_services($class) ) { - my $column_width = Catalyst::Utils::term_width() - 8 - 9; - my $t = Text::SimpleTable->new( [ $column_width, 'Class' ], [ 8, 'Type' ] ); - $t->row( $_ => ref($comps->{$_}) ? 'instance' : 'class' ) for keys %$comps; + my $column_width = Catalyst::Utils::term_width() - 16 - 9; + my $t = Text::SimpleTable->new( [ $column_width, 'Class' ], [ 16, 'Lifecycle' ] ); + + # FIXME + # I don't really know what we're going to show here + while (my ($class, $info) = each %$comps) { + my $lifecycle = $info->{backcompat_service} + ? $info->{backcompat_service}->lifecycle + : $info->{service}->lifecycle + ; + $t->row( $class, $lifecycle ); + } $class->log->debug( "Loaded components:\n" . $t->draw . "\n" ); } @@ -1439,16 +1458,25 @@ Returns a hash of components. sub components { my ( $class, $comps ) = @_; + # FIXME + # this is very wrong # people create components calling this sub directly, before setup + # also, $class->log doesn't work before setup_log $class->setup_config unless $class->container; my $container = $class->container; if ( $comps ) { + $class->log->warn(q{You are adding components using Catalyst's components method.}); + $class->log->warn(q{This behaviour is deprecated, please read}); + $class->log->warn(q{Catalyst::IOC::Container's documentation for better ways to do that.}); $container->add_component( $_ ) for keys %$comps; } - return $container->get_all_components($class); + return + ref($class) ? $container->get_all_components($class) + : $container->get_all_singleton_lifecycle_components + ; } =head2 $c->context_class