X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=b38be49f847921ba79d89f524a4460a64782a556;hp=2f0fb0d01b4f3a897e2d32dedf78562f94f7e3a2;hb=33632a44f189d7d49c8060076e382f2df36d7283;hpb=62a6df80212f937ce5ecf1577b95d4946f43ed2b diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 2f0fb0d..b38be49 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1,10 +1,11 @@ package Catalyst; use Moose; +use Moose::Meta::Class (); extends 'Catalyst::Component'; use Moose::Util qw/find_meta/; use bytes; -use Scope::Upper (); +use B::Hooks::EndOfScope (); use Catalyst::Exception; use Catalyst::Log; use Catalyst::Request; @@ -75,7 +76,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.80002'; +our $VERSION = '5.80005'; { my $dev_version = $VERSION =~ /_\d{2}$/; @@ -815,7 +816,7 @@ The config method is present on all Catalyst components, and configuration will be merged when an application is started. Configuration loaded with L takes precedence over other configuration, followed by configuration in your top level C class. These two -configurations are merged, and then configuration data whos hash key matches a +configurations are merged, and then configuration data whose hash key matches a component name is merged with configuration for that component. The configuration for a component is then passed to the C method when a @@ -903,7 +904,9 @@ Returns the engine instance. See L. =head2 $c->path_to(@path) Merges C<@path> with C<< $c->config->{home} >> and returns a -L object. +L object. Note you can usually use this object as +a filename, but sometimes you will have to explicitly stringify it +yourself by calling the C<<->stringify>> method. For example: @@ -1099,10 +1102,17 @@ 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). - Scope::Upper::reap(sub { + B::Hooks::EndOfScope::on_scope_end { + return if $@; my $meta = Class::MOP::get_metaclass_by_name($class); + if ( $meta->is_immutable && ! { $meta->immutable_options }->{inline_constructor} ) { + warn "You made your application class ($class) immutable, " + . "but did not inline the constructor.\n" + . "This will break catalyst, please pass " + . "(replace_constructor => 1) when making your class immutable.\n"; + } $meta->make_immutable(replace_constructor => 1) unless $meta->is_immutable; - }, Scope::Upper::SCOPE(1)); + }; $class->setup_finalize; } @@ -1153,7 +1163,7 @@ using C<< $c->req->captures >>. $c->uri_for($c->action, $c->req->captures); # For the Foo action in the Bar controller - $c->uri_for($c->controller->('Bar')->action_for('Foo'), $c->req->captures); + $c->uri_for($c->controller('Bar')->action_for('Foo'), $c->req->captures); =back @@ -1182,7 +1192,7 @@ sub uri_for { ( scalar @args && ref $args[$#args] eq 'HASH' ? pop @args : {} ); carp "uri_for called with undef argument" if grep { ! defined $_ } @args; - s/([^$URI::uric])/$URI::Escape::escapes{$1}/go for @args; + s/([^A-Za-z0-9\-_.!~*'()])/$URI::Escape::escapes{$1}/go for @args; unshift(@args, $path); @@ -1216,7 +1226,7 @@ sub uri_for { $_ = "$_"; utf8::encode( $_ ) if utf8::is_utf8($_); # using the URI::Escape pattern here so utf8 chars survive - s/([^A-Za-z0-9\-_.!~*'() ])/$URI::Escape::escapes{$1}/go; + s/([^A-Za-z0-9\-_.!~*'()])/$URI::Escape::escapes{$1}/go; s/ /+/g; "${key}=$_"; } ( ref $val eq 'ARRAY' ? @$val : $val )); } @keys); @@ -2166,9 +2176,9 @@ sub setup_components { =cut sub _controller_init_base_classes { - my ($class, $component) = @_; + my ($app_class, $component) = @_; foreach my $class ( reverse @{ mro::get_linear_isa($component) } ) { - Moose->init_meta( for_class => $class ) + Moose::Meta::Class->initialize( $class ) unless find_meta($class); } } @@ -2472,9 +2482,6 @@ the plugin name does not begin with C. my ( $proto, $plugin, $instant ) = @_; my $class = ref $proto || $proto; - # no ignore_loaded here, the plugin may already have been - # defined in memory and we don't want to error on "no file" if so - Class::MOP::load_class( $plugin ); $proto->_plugins->{$plugin} = 1; @@ -2495,14 +2502,26 @@ the plugin name does not begin with C. $class->_plugins( {} ) unless $class->_plugins; $plugins ||= []; - for my $plugin ( reverse @$plugins ) { - unless ( $plugin =~ s/\A\+// ) { - $plugin = "Catalyst::Plugin::$plugin"; - } + my @plugins = map { s/\A\+// ? $_ : "Catalyst::Plugin::$_" } @$plugins; + + for my $plugin ( reverse @plugins ) { + Class::MOP::load_class($plugin); + my $meta = find_meta($plugin); + next if $meta && $meta->isa('Moose::Meta::Role'); $class->_register_plugin($plugin); } + + my @roles = + map { $_->name } + grep { $_ && blessed($_) && $_->isa('Moose::Meta::Role') } + map { find_meta($_) } + @plugins; + + Moose::Util::apply_all_roles( + $class => @roles + ) if @roles; } } @@ -2694,6 +2713,8 @@ dkubb: Dan Kubb Drew Taylor +dwc: Daniel Westermann-Clark + esskar: Sascha Kiefer fireartist: Carl Franks @@ -2742,6 +2763,8 @@ phaylon: Robert Sedlacek rafl: Florian Ragwitz +random: Roland Lammel + sky: Arthur Bergman the_jester: Jesse Sheidlower