[Catalyst-commits] r7153 - trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication

jayk at dev.catalyst.perl.org jayk at dev.catalyst.perl.org
Thu Nov 22 00:14:33 GMT 2007


Author: jayk
Date: 2007-11-22 00:14:33 +0000 (Thu, 22 Nov 2007)
New Revision: 7153

Modified:
   trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/Realm.pm
Log:
Changing module naming from Catalyst::Plugin::Authentication to 
Catalyst::Authentication.

Modified: trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/Realm.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/Realm.pm	2007-11-21 18:57:26 UTC (rev 7152)
+++ trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/Realm.pm	2007-11-22 00:14:33 UTC (rev 7153)
@@ -21,7 +21,7 @@
 
     # use the Null store as a default
     if( ! exists $config->{store}{class} ) {
-        $config->{store}{class} = '+Catalyst::Plugin::Authentication::Store::Null';
+        $config->{store}{class} = '+Catalyst::Authentication::Store::Null';
         $app->log->debug( qq(No Store specified for realm "$realmname", using the Null store.) );
     } 
     my $storeclass = $config->{'store'}{'class'};
@@ -29,29 +29,51 @@
     ## follow catalyst class naming - a + prefix means a fully qualified class, otherwise it's
     ## taken to mean C::P::A::Store::(specifiedclass)
     if ($storeclass !~ /^\+(.*)$/ ) {
-        $storeclass = "Catalyst::Plugin::Authentication::Store::${storeclass}";
+        $storeclass = "Catalyst::Authentication::Store::${storeclass}";
     } else {
         $storeclass = $1;
     }
 
     # a little niceness - since most systems seem to use the password credential class, 
     # if no credential class is specified we use password.
-    $config->{credential}{class} ||= '+Catalyst::Plugin::Authentication::Credential::Password';
+    $config->{credential}{class} ||= '+Catalyst::Authentication::Credential::Password';
 
     my $credentialclass = $config->{'credential'}{'class'};
     
     ## follow catalyst class naming - a + prefix means a fully qualified class, otherwise it's
-    ## taken to mean C::P::A::Credential::(specifiedclass)
+    ## taken to mean C::A::Credential::(specifiedclass)
     if ($credentialclass !~ /^\+(.*)$/ ) {
-        $credentialclass = "Catalyst::Plugin::Authentication::Credential::${credentialclass}";
+        $credentialclass = "Catalyst::Authentication::Credential::${credentialclass}";
     } else {
         $credentialclass = $1;
     }
     
-    # if we made it here - we have what we need to load the classes;
-    Catalyst::Utils::ensure_class_loaded( $credentialclass );
-    Catalyst::Utils::ensure_class_loaded( $storeclass );
+    # if we made it here - we have what we need to load the classes
     
+    ### BACKWARDS COMPATIBILITY - DEPRECATION WARNING:  
+    ###  we must eval the ensure_class_loaded - because we might need to try the old-style
+    ###  ::Plugin:: module naming if the standard method fails. 
+    
+    eval {
+        Catalyst::Utils::ensure_class_loaded( $credentialclass );
+    };
+    
+    if ($@) {
+        $app->log->warn( qq(Credential class "$credentialclass" not found, trying deprecated ::Plugin:: style naming. ) );
+        $credentialclass =~ s/Catalyst::Authentication/Catalyst::Plugin::Authentication/;
+        Catalyst::Utils::ensure_class_loaded( $credentialclass );
+    }
+    
+    eval {
+        Catalyst::Utils::ensure_class_loaded( $storeclass );
+    };
+    
+    if ($@) {
+        $app->log->warn( qq(Store class "$storeclass" not found, trying deprecated ::Plugin:: style naming. ) );
+        $storeclass =~ s/Catalyst::Authentication/Catalyst::Plugin::Authentication/;
+        Catalyst::Utils::ensure_class_loaded( $storeclass );
+    }
+    
     # BACKWARDS COMPATIBILITY - if the store class does not define find_user, we define it in terms 
     # of get_user and add it to the class.  this is because the auth routines use find_user, 
     # and rely on it being present. (this avoids per-call checks)




More information about the Catalyst-commits mailing list