summaryrefslogtreecommitdiff
path: root/django/utils/module_loading.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-04-25 13:23:14 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-04-25 13:23:14 +0000
commita43464d67eee4fde5e670d5c4086bdf6e0048e06 (patch)
tree67f10ded0baf672c7bbfc3329ac0a8a016739416 /django/utils/module_loading.py
parent5226525736bd8394591df13fa7c11c75ac850ddd (diff)
[1.1.X] Fixed #13404 -- Reworked module_has_submodule() to allow it to 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
Diffstat (limited to 'django/utils/module_loading.py')
-rw-r--r--django/utils/module_loading.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py
index b23336e9df..9bcdd276fd 100644
--- a/django/utils/module_loading.py
+++ b/django/utils/module_loading.py
@@ -2,18 +2,17 @@ import os
import imp
def module_has_submodule(mod, submod_name):
- # If the module was loaded from an egg, __loader__ will be set and
+ # If the module was loaded from an egg, __loader__ will be set and
# its find_module must be used to search for submodules.
loader = getattr(mod, '__loader__', None)
if loader:
- mod_path = "%s.%s" % (mod.__name__, submod_name)
- mod_path = mod_path[len(loader.prefix):]
+ mod_path = "%s.%s" % (mod.__name__.rsplit('.',1)[-1], submod_name)
x = loader.find_module(mod_path)
if x is None:
# zipimport.zipimporter.find_module is documented to take
- # dotted paths but in fact through Pyton 2.7 is observed
+ # dotted paths but in fact through Python 2.7 is observed
# to require os.sep in place of dots...so try using os.sep
- # if the dotted path version failed to find the requested
+ # if the dotted path version failed to find the requested
# submodule.
x = loader.find_module(mod_path.replace('.', os.sep))
return x is not None