Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/flask_restful.mochi failed with the error KeyError: 'startswith' #23

Open
tlvu opened this issue Apr 15, 2015 · 1 comment
Open

Comments

@tlvu
Copy link
Contributor

tlvu commented Apr 15, 2015

Traceback (most recent call last):
File "/root/venv/mochi/bin/mochi", line 9, in
load_entry_point('mochi==0.2.1', 'console_scripts', 'mochi')()
File "/root/venv/mochi/lib/python3.4/site-packages/mochi-0.2.1-py3.4.egg/mochi/core/main.py", line 192, in main
load_file(args.file, global_env)
File "/root/venv/mochi/lib/python3.4/site-packages/mochi-0.2.1-py3.4.egg/mochi/core/main.py", line 49, in load_file
return exec(compile_file(path), env)
File "flask_restful.mochi", line 6, in
app = Flask(name)
File "/root/venv/mochi/lib/python3.4/site-packages/flask/app.py", line 331, in init
instance_path = self.auto_find_instance_path()
File "/root/venv/mochi/lib/python3.4/site-packages/flask/app.py", line 622, in auto_find_instance_path
prefix, package_path = find_package(self.import_name)
File "/root/venv/mochi/lib/python3.4/site-packages/flask/helpers.py", line 661, in find_package
loader = pkgutil.get_loader(root_mod_name)
File "/usr/lib/python3.4/pkgutil.py", line 467, in get_loader
return find_loader(fullname)
File "/usr/lib/python3.4/pkgutil.py", line 477, in find_loader
if fullname.startswith('.'):
File "/root/venv/mochi/lib/python3.4/site-packages/mochi-0.2.1-py3.4.egg/mochi/core/global_env.py", line 21, in getattr
return self[attr]
KeyError: 'startswith'

@pya
Copy link
Contributor

pya commented Apr 16, 2015

This can be resolved by placing this in the file flask_restful.mochi:

import sys

sys.modules.pop(__name__)

The module __main__ is replaced by an instance of core.global_env.AttrDict. Deleting it fixes the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants