[Catalyst-commits] r11134 - in Catalyst-Runtime/5.80/trunk: . lib
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Wed Aug 12 11:03:07 GMT 2009
Author: t0m
Date: 2009-08-12 11:03:06 +0000 (Wed, 12 Aug 2009)
New Revision: 11134
Modified:
Catalyst-Runtime/5.80/trunk/Makefile.PL
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Log:
Make the code much clearer about what is going on, and remove the horrible map and grep which I hated.
Modified: Catalyst-Runtime/5.80/trunk/Makefile.PL
===================================================================
--- Catalyst-Runtime/5.80/trunk/Makefile.PL 2009-08-12 02:54:52 UTC (rev 11133)
+++ Catalyst-Runtime/5.80/trunk/Makefile.PL 2009-08-12 11:03:06 UTC (rev 11134)
@@ -12,6 +12,7 @@
name 'Catalyst-Runtime';
all_from 'lib/Catalyst/Runtime.pm';
+requires 'List::MoreUtils';
requires 'namespace::autoclean';
requires 'namespace::clean';
requires 'B::Hooks::EndOfScope' => '0.08';
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-08-12 02:54:52 UTC (rev 11133)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-08-12 11:03:06 UTC (rev 11134)
@@ -27,6 +27,7 @@
use Tree::Simple qw/use_weak_refs/;
use Tree::Simple::Visitor::FindByUID;
use Class::C3::Adopt::NEXT;
+use List::MoreUtils qw/uniq/;
use attributes;
use utf8;
use Carp qw/croak carp shortmess/;
@@ -2153,8 +2154,6 @@
my @comps = sort { length $a <=> length $b }
$class->locate_components($config);
- my %comps = map { $_ => 1 } @comps;
-
my $deprecated_component_names = grep { /::[CMV]::/ } @comps;
$class->log->warn(qq{Your application is using the deprecated ::[MVC]:: type naming scheme.\n}.
qq{Please switch your class names to ::Model::, ::View:: and ::Controller: as appropriate.\n}
@@ -2167,23 +2166,15 @@
# we know M::P::O found a file on disk so this is safe
Catalyst::Utils::ensure_class_loaded( $component, { ignore_loaded => 1 } );
- #Class::MOP::load_class($component);
- my @packages = $class->expand_component_module( $component, $config );
+ # Needs to be done as soon as the component is loaded, as loading a sub-component
+ # (next time round the loop) can cause us to get the wrong metaclass..
+ $class->_controller_init_base_classes($component);
+ }
- my %modules = (
- map {
- $_ => $class->setup_component( $_ )
- } grep {
- # we preloaded $component above, so we must allow it here again
- # -- rjbs, 2009-08-11
- ($_ eq $component) or (not exists $comps{$_})
- } @packages
- );
-
- for my $key ( keys %modules ) {
- $class->components->{ $key } = $modules{ $key };
- }
+ for my $component (uniq map { $class->expand_component_module( $_, $config ) } @comps ) {
+ $class->_controller_init_base_classes($component); # Also cover inner packages
+ $class->components->{ $component } = $class->setup_component($component);
}
}
@@ -2238,8 +2229,13 @@
=cut
+# FIXME - Ugly, ugly hack to ensure the we force initialize non-moose base classes
+# nearest to Catalyst::Controller first, no matter what order stuff happens
+# to be loaded. There are TODO tests in Moose for this, see
+# f2391d17574eff81d911b97be15ea51080500003
sub _controller_init_base_classes {
my ($app_class, $component) = @_;
+ return unless $component->isa('Catalyst::Controller');
foreach my $class ( reverse @{ mro::get_linear_isa($component) } ) {
Moose::Meta::Class->initialize( $class )
unless find_meta($class);
@@ -2253,14 +2249,6 @@
return $component;
}
- # FIXME - Ugly, ugly hack to ensure the we force initialize non-moose base classes
- # nearest to Catalyst::Controller first, no matter what order stuff happens
- # to be loaded. There are TODO tests in Moose for this, see
- # f2391d17574eff81d911b97be15ea51080500003
- if ($component->isa('Catalyst::Controller')) {
- $class->_controller_init_base_classes($component);
- }
-
my $suffix = Catalyst::Utils::class2classsuffix( $component );
my $config = $class->config->{ $suffix } || {};
# Stash _component_name in the config here, so that custom COMPONENT
More information about the Catalyst-commits
mailing list