X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FBase.pm;h=a0f81ef0b5fd964dd760ab31fbd1ab7d87a49c02;hp=789c6ab9f987b41334456a1761e787f5c9e36946;hb=9b793a51e8b5edb92c9fad8a87323be0235961d4;hpb=c5c6debaeee50edaeec51abfbf82787e5395ab33 diff --git a/lib/Catalyst/Base.pm b/lib/Catalyst/Base.pm index 789c6ab..a0f81ef 100644 --- a/lib/Catalyst/Base.pm +++ b/lib/Catalyst/Base.pm @@ -2,10 +2,11 @@ package Catalyst::Base; use strict; use base qw/Class::Data::Inheritable Class::Accessor::Fast/; - +use Catalyst::Utils; use Catalyst::Exception; use NEXT; +# Some caches... __PACKAGE__->mk_classdata($_) for qw/_attr_cache _action_cache _config/; __PACKAGE__->_attr_cache( {} ); __PACKAGE__->_action_cache( [] ); @@ -71,11 +72,22 @@ component loader with config() support and a process() method placeholder. sub new { my ( $self, $c ) = @_; - + + # You'll find yourself naked and strung from a tree if you ever + # remove this again, k? :) + my $class = ref $self || $self; + my $appname = Catalyst::Utils::class2appclass($class); + my $suffix = Catalyst::Utils::class2classsuffix($class); + my $appconfig = {}; + + # Not catched, for compatibility with non Catalyst apps + eval '$appconfig = $appname->config->{$suffix} || {}'; + my $config = { %{ $self->config }, %{$appconfig} }; + # Temporary fix, some components does not pass context to constructor my $arguments = ( ref( $_[-1] ) eq 'HASH' ) ? $_[-1] : {}; - return $self->NEXT::new( { %{ $self->config }, %{ $arguments } } ); + return $self->NEXT::new( { %{$config}, %{$arguments} } ); } # remember to leave blank lines between the consecutive =item's @@ -107,9 +119,8 @@ sub config { sub process { - Catalyst::Exception->throw( - message => ( ref $_[0] || $_[0] ) . " did not override Catalyst::Base::process" - ); + Catalyst::Exception->throw( message => ( ref $_[0] || $_[0] ) + . " did not override Catalyst::Base::process" ); } =item FETCH_CODE_ATTRIBUTES