reverted custom_install tests
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.1.0 (2012-10-14 18:29:10) dev
|
Version 2.1.0 (2012-10-14 20:07:50) dev
|
||||||
|
|||||||
+7
-15
@@ -25,9 +25,6 @@ def track_changes(track=True):
|
|||||||
def is_tracking_changes():
|
def is_tracking_changes():
|
||||||
return TRACK_CHANGES
|
return TRACK_CHANGES
|
||||||
|
|
||||||
class CustomImportException(ImportError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1):
|
def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1):
|
||||||
"""
|
"""
|
||||||
The web2py custom importer. Like the standard Python importer but it
|
The web2py custom importer. Like the standard Python importer but it
|
||||||
@@ -47,7 +44,6 @@ def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1):
|
|||||||
and level<=0 \
|
and level<=0 \
|
||||||
and not name.split('.')[0] in INVALID_MODULES \
|
and not name.split('.')[0] in INVALID_MODULES \
|
||||||
and isinstance(globals, dict):
|
and isinstance(globals, dict):
|
||||||
import_tb = None
|
|
||||||
try:
|
try:
|
||||||
items = current.request.folder.split(os.path.sep)
|
items = current.request.folder.split(os.path.sep)
|
||||||
if not items[-1]: items = items[:-1]
|
if not items[-1]: items = items[:-1]
|
||||||
@@ -56,26 +52,22 @@ def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1):
|
|||||||
# import like "import x" or "import x.y"
|
# import like "import x" or "import x.y"
|
||||||
result = None
|
result = None
|
||||||
for itemname in name.split("."):
|
for itemname in name.split("."):
|
||||||
|
new_mod = base_importer(
|
||||||
|
modules_prefix, globals,locals, [itemname], level)
|
||||||
|
try:
|
||||||
|
result = result or new_mod.__dict__[itemname]
|
||||||
|
except KeyError, e:
|
||||||
|
raise ImportError, 'Cannot import module %s' % str(e)
|
||||||
modules_prefix += "." + itemname
|
modules_prefix += "." + itemname
|
||||||
base_importer(
|
|
||||||
modules_prefix, globals,locals, [], level)
|
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
# import like "from x import a, b, ..."
|
# import like "from x import a, b, ..."
|
||||||
pname = modules_prefix + "." + name
|
pname = modules_prefix + "." + name
|
||||||
return base_importer(pname, globals, locals, fromlist, level)
|
return base_importer(pname, globals, locals, fromlist, level)
|
||||||
except ImportError, e1:
|
except ImportError, e1:
|
||||||
import_tb = sys.exc_info()[2]
|
pass # the module does not exist
|
||||||
try:
|
|
||||||
return NATIVE_IMPORTER(name,globals,locals,fromlist,level)
|
|
||||||
except ImportError, e3:
|
|
||||||
raise ImportError, e1, import_tb.tb_next # there an import error in the module
|
|
||||||
except Exception, e2:
|
except Exception, e2:
|
||||||
raise e2 # there is an error in the module
|
raise e2 # there is an error in the module
|
||||||
finally:
|
|
||||||
if import_tb:
|
|
||||||
import_tb = None
|
|
||||||
|
|
||||||
return NATIVE_IMPORTER(name,globals,locals,fromlist,level)
|
return NATIVE_IMPORTER(name,globals,locals,fromlist,level)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user