X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=3471a6c4bdfa9cf16afadfc555aa6fdfe95eccf8;hb=6b2a933b5b3820e494f9b5804c7c2eb6083bcf09;hp=d3870990775415d9311e9afd9e9089a324a66016;hpb=0f56bbcf00b69a018aa6be442200b917b3e9f9a2;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index d387099..3471a6c 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -8,7 +8,7 @@ use Moose; use Class::MOP::Object (); extends 'Catalyst::Component'; use bytes; -use B::Hooks::EndOfScope; +use Scope::Upper (); use Catalyst::Exception; use Catalyst::Log; use Catalyst::Request; @@ -862,11 +862,19 @@ loads and instantiates the given class. MyApp->plugin( 'prototype', 'HTML::Prototype' ); $c->prototype->define_javascript_functions; + +B This method of adding plugins is deprecated. The ability +to add plugins like this B in a Catalyst 5.9. +Please do not use this functionality in new code. =cut sub plugin { my ( $class, $name, $plugin, @args ) = @_; + + # See block comment in t/unit_core_plugin.t + $class->log->debug(qq/Adding plugin using the ->plugin method is deprecated, and will be removed in Catalyst 5.9/); + $class->_register_plugin( $plugin, 1 ); eval { $plugin->import }; @@ -983,7 +991,7 @@ EOF : $class->log->debug(q/Couldn't find home/); } - # Call plugins setup + # Call plugins setup, this is stupid and evil. { no warnings qw/redefine/; local *setup = sub { }; @@ -1024,10 +1032,10 @@ EOF # Note however that we have to do the work on scope end, so that method # modifiers work correctly in MyApp (as you have to call setup _before_ # applying modifiers). - on_scope_end { + Scope::Upper::reap(sub { my $meta = $class->Moose::Object::meta(); $meta->make_immutable unless $meta->is_immutable; - }; + }, 1); $class->setup_finished(1); } @@ -2226,19 +2234,19 @@ or if the C<$CATALYST_DEBUG> environment variable is set to a true value. Note that if the log has already been setup, by either a previous call to C or by a call such as C<< __PACKAGE__->log( MyLogger->new ) >>, -that this method won't actually set up the log. +that this method won't actually set up the log object. =cut sub setup_log { my ( $class, $levels ) = @_; - my %levels; + $levels ||= ''; + $levels =~ s/^\s+//; + $levels =~ s/\s+$//; + my %levels = map { $_ => 1 } split /\s*,\s*/, $levels || ''; + unless ( $class->log ) { - $levels ||= ''; - $levels =~ s/^\s+//; - $levels =~ s/\s+$//; - %levels = map { $_ => 1 } split /\s*,\s*/, $levels || ''; $class->log( Catalyst::Log->new(keys %levels) ); }