[Catalyst-commits] r6701 - in trunk/Catalyst-Runtime: . lib lib/Catalyst

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Tue Aug 21 23:25:23 GMT 2007


Author: matthewt
Date: 2007-08-21 23:25:23 +0100 (Tue, 21 Aug 2007)
New Revision: 6701

Modified:
   trunk/Catalyst-Runtime/Changes
   trunk/Catalyst-Runtime/lib/Catalyst.pm
   trunk/Catalyst-Runtime/lib/Catalyst/Utils.pm
Log:
fix plugin loading

Modified: trunk/Catalyst-Runtime/Changes
===================================================================
--- trunk/Catalyst-Runtime/Changes	2007-08-21 18:18:25 UTC (rev 6700)
+++ trunk/Catalyst-Runtime/Changes	2007-08-21 22:25:23 UTC (rev 6701)
@@ -4,6 +4,8 @@
         - Moved Manual.pod to Manual.pm and clarified status of 
           Catalyst-Manual dist
         - Doc patches to Catalyst::Controller
+        - remove ignore_loaded from plugin load, commenting why
+        - document the ignore_loaded feature in Catalyst::Utils
 
 5.7008  2007-08-13 08:40:00
         - Added $c->request->query_keywords for getting the keywords

Modified: trunk/Catalyst-Runtime/lib/Catalyst/Utils.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst/Utils.pm	2007-08-21 18:18:25 UTC (rev 6700)
+++ trunk/Catalyst-Runtime/lib/Catalyst/Utils.pm	2007-08-21 22:25:23 UTC (rev 6701)
@@ -233,10 +233,15 @@
     return $request;
 }
 
-=head2 ensure_class_loaded($class_name)
+=head2 ensure_class_loaded($class_name, \%opts)
 
 Loads the class unless it already has been loaded.
 
+If $opts{ignore_loaded} is true always tries the require whether the package
+already exists or not. Only pass this if you're either (a) sure you know the
+file exists on disk or (b) have code to catch the file not found exception
+that will result if it doesn't.
+
 =cut
 
 sub ensure_class_loaded {

Modified: trunk/Catalyst-Runtime/lib/Catalyst.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst.pm	2007-08-21 18:18:25 UTC (rev 6700)
+++ trunk/Catalyst-Runtime/lib/Catalyst.pm	2007-08-21 22:25:23 UTC (rev 6701)
@@ -1872,6 +1872,11 @@
     my %comps = map { $_ => 1 } @comps;
     
     for my $component ( @comps ) {
+
+        # We pass ignore_loaded here so that overlay files for (e.g.)
+        # Model::DBI::Schema sub-classes are loaded - if it's in @comps
+        # we know M::P::O found a file on disk so this is safe
+
         Catalyst::Utils::ensure_class_loaded( $component, { ignore_loaded => 1 } );
 
         my $module  = $class->setup_component( $component );
@@ -2149,8 +2154,11 @@
         my ( $proto, $plugin, $instant ) = @_;
         my $class = ref $proto || $proto;
 
-        Catalyst::Utils::ensure_class_loaded( $plugin, { ignore_loaded => 1 } );
+        # 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
 
+        Catalyst::Utils::ensure_class_loaded( $plugin );
+
         $proto->_plugins->{$plugin} = 1;
         unless ($instant) {
             no strict 'refs';




More information about the Catalyst-commits mailing list