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 has wrong __main__ #28

Closed
pya opened this issue Apr 16, 2015 · 1 comment
Closed

examples/flask_restful.mochi has wrong __main__ #28

pya opened this issue Apr 16, 2015 · 1 comment

Comments

@pya
Copy link
Contributor

pya commented Apr 16, 2015

The example flask_restful.mochi does not run:

mochi flask_restful.mochi 
Traceback (most recent call last):
  File "/Users/mike/anaconda/envs/py34/bin/mochi", line 9, in <module>
    load_entry_point('mochi==0.2.1', 'console_scripts', 'mochi')()
  File "/Users/mike/anaconda/envs/py34/lib/python3.4/site-packages/mochi/core/main.py", line 174, in main
    load_file(args.file, global_env)
  File "/Users/mike/anaconda/envs/py34/lib/python3.4/site-packages/mochi/core/main.py", line 50, in load_file
    return exec(compile_file(path), env)
  File "flask_restful.mochi", line 8, in <module>
    app = Flask(__name__)
  File "/Users/mike/anaconda/envs/py34/lib/python3.4/site-packages/flask/app.py", line 331, in __init__
    instance_path = self.auto_find_instance_path()
  File "/Users/mike/anaconda/envs/py34/lib/python3.4/site-packages/flask/app.py", line 622, in auto_find_instance_path
    prefix, package_path = find_package(self.import_name)
  File "/Users/mike/anaconda/envs/py34/lib/python3.4/site-packages/flask/helpers.py", line 661, in find_package
    loader = pkgutil.get_loader(root_mod_name)
  File "/Users/mike/anaconda/envs/py34/lib/python3.4/pkgutil.py", line 471, in get_loader
    return find_loader(fullname)
  File "/Users/mike/anaconda/envs/py34/lib/python3.4/pkgutil.py", line 481, in find_loader
    if fullname.startswith('.'):
  File "/Users/mike/anaconda/envs/py34/lib/python3.4/site-packages/mochi/core/global_env.py", line 21, in __getattr__
    return self[attr]
KeyError: 'startswith'

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.

@pya pya closed this as completed Apr 16, 2015
@pya
Copy link
Contributor Author

pya commented Apr 16, 2015

Duplicate of #23.

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

1 participant