[Jifty-commit] r4590 - in jifty/trunk: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Nov 30 17:39:08 EST 2007


Author: sartak
Date: Fri Nov 30 17:39:08 2007
New Revision: 4590

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Util.pm

Log:
 r48454 at onn:  sartak | 2007-11-30 17:38:10 -0500
 Rename $pkg to $file in Jifty::Util->_require, and don't append .pm if it's already there


Modified: jifty/trunk/lib/Jifty/Util.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Util.pm	(original)
+++ jifty/trunk/lib/Jifty/Util.pm	Fri Nov 30 17:39:08 2007
@@ -256,16 +256,21 @@
 
     return 1 if $self->already_required($class);
 
-    my $pkg = $class .".pm";
-    $pkg =~ s/::/\//g;
-    my $retval = eval  {CORE::require "$pkg"} ;
+    # .pm might already be there in a weird interaction in Module::Pluggable
+    my $file = $class;
+    $file .= ".pm"
+        unless $file =~ /\.pm$/;
+
+    $file =~ s/::/\//g;
+
+    my $retval = eval  {CORE::require "$file"} ;
     my $error = $@;
     if (my $message = $error) { 
         $message =~ s/ at .*?\n$//;
-        if ($args{'quiet'} and $message =~ /^Can't locate $pkg/) {
+        if ($args{'quiet'} and $message =~ /^Can't locate $file/) {
             return 0;
         }
-        elsif ( $error !~ /^Can't locate $pkg/) {
+        elsif ( $error !~ /^Can't locate $file/) {
             die $error;
         } else {
             Jifty->log->error(sprintf("$message at %s line %d\n", (caller(1))[1,2]));


More information about the Jifty-commit mailing list