Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.1.X] Fixed #13404 -- Reworked module_has_submodule() to allow it t…

…o work under AppEngine. Thanks to Waldemar Kornewald for the report and testing help.

Backport of r13023 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@13024 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a43464d67eee4fde5e670d5c4086bdf6e0048e06 1 parent 5226525
Russell Keith-Magee authored April 25, 2010

Showing 1 changed file with 4 additions and 5 deletions. Show diff stats Hide diff stats

  1. 9  django/utils/module_loading.py
9  django/utils/module_loading.py
@@ -2,18 +2,17 @@
2 2
 import imp
3 3
 
4 4
 def module_has_submodule(mod, submod_name):
5  
-    # If the module was loaded from an egg, __loader__ will be set and 
  5
+    # If the module was loaded from an egg, __loader__ will be set and
6 6
     # its find_module must be used to search for submodules.
7 7
     loader = getattr(mod, '__loader__', None)
8 8
     if loader:
9  
-        mod_path = "%s.%s" % (mod.__name__, submod_name)
10  
-        mod_path = mod_path[len(loader.prefix):]
  9
+        mod_path = "%s.%s" % (mod.__name__.rsplit('.',1)[-1], submod_name)
11 10
         x = loader.find_module(mod_path)
12 11
         if x is None:
13 12
             # zipimport.zipimporter.find_module is documented to take
14  
-            # dotted paths but in fact through Pyton 2.7 is observed 
  13
+            # dotted paths but in fact through Python 2.7 is observed
15 14
             # to require os.sep in place of dots...so try using os.sep
16  
-            # if the dotted path version failed to find the requested 
  15
+            # if the dotted path version failed to find the requested
17 16
             # submodule.
18 17
             x = loader.find_module(mod_path.replace('.', os.sep))
19 18
         return x is not None

0 notes on commit a43464d

Please sign in to comment.
Something went wrong with that request. Please try again.