pulling custom_import from upstream
This commit is contained in:
1 parent
d450d48e99
commit
c58c6157e9
1 file changed
+3
-2
@@ -12,8 +12,9 @@ from gluon import current
|
|||||||
NATIVE_IMPORTER = __builtin__.__import__
|
NATIVE_IMPORTER = __builtin__.__import__
|
||||||
INVALID_MODULES = set(('', 'gluon', 'applications', 'custom_import'))
|
INVALID_MODULES = set(('', 'gluon', 'applications', 'custom_import'))
|
||||||
|
|
||||||
|
|
||||||
# backward compatibility API
|
# backward compatibility API
|
||||||
|
|
||||||
|
|
||||||
def custom_import_install():
|
def custom_import_install():
|
||||||
if __builtin__.__import__ != custom_importer:
|
if __builtin__.__import__ != custom_importer:
|
||||||
INVALID_MODULES.update(sys.modules.keys())
|
INVALID_MODULES.update(sys.modules.keys())
|
||||||
@@ -69,7 +70,7 @@ def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1):
|
|||||||
result = None
|
result = None
|
||||||
for itemname in name.split("."):
|
for itemname in name.split("."):
|
||||||
new_mod = base_importer(
|
new_mod = base_importer(
|
||||||
modules_prefix, globals,locals, [itemname], level)
|
modules_prefix, globals, locals, [itemname], level)
|
||||||
try:
|
try:
|
||||||
result = result or new_mod.__dict__[itemname]
|
result = result or new_mod.__dict__[itemname]
|
||||||
except KeyError, e:
|
except KeyError, e:
|
||||||
|
|||||||
Reference in new issue
Block a user