Traceback (most recent call last):
File "/installdir/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/installdir/web2py/applications/wavilon_portal/models/db.py", line 10, in <module>
import nltk.data
File "/installdir/web2py/gluon/custom_import.py", line 77, in custom_importer
raise ImportError, 'Cannot import module %s' % str(e)
ImportError: Cannot import module 'nltk'import sys
sys.path=<sys_path_in_model>
import nltk.dataI have a problem with an import in my model:
return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
# if not relative and not from applications:
if hasattr(current, 'request') \
and level <= 0 \
and not name.split('.')[0] in INVALID_MODULES \
and isinstance(globals, dict):The problem is this code in custom_import.py
FORMAT="%s -> %-40s %-10s %-10s %-10s %-10s"
# if not relative and not from applications:
if hasattr(current, 'request') \
and level <= 0 \
and not name.split('.')[0] in INVALID_MODULES \
and isinstance(globals, dict):
print FORMAT % ("custom", name, hasattr(current, 'request'), level, name.split('.')[0] in INVALID_MODULES, isinstance(globals, dict))
...
finally:
if import_tb:
import_tb = None
print FORMAT % ("native", name, hasattr(current, 'request'), level, name.split('.')[0] in INVALID_MODULES, isinstance(globals, dict))
return NATIVE_IMPORTER(name, globals, locals, fromlist, level)native -> random True -1 True True
custom -> nltk.data True -1 False True
native -> __future__ True -1 True True
native -> os True -1 True True
custom -> internals True -1 False True
native -> subprocess True -1 True True
native -> os True -1 True True
native -> os.path True -1 True True
native -> re True -1 True True
native -> warnings True -1 True True
native -> textwrap True -1 True True
native -> types True -1 True True
native -> sys True -1 True True
native -> stat True -1 True True INVALID_MODULES = set(('', 'gluon', 'applications', 'custom_import'))
INVALID_MODULES = set(('', 'gluon', 'applications', 'custom_import', 'nltk', 'collocations', 'numpy', 'testing'))
def custom_import_install():
if __builtin__.__import__ == NATIVE_IMPORTER:
INVALID_MODULES.update(sys.modules.keys())
__builtin__.__import__ = custom_importer