acoomans / flask-autodoc

Flask autodoc automatically creates an online documentation for your flask application.
MIT License
98 stars 49 forks source link

gae keyerror main #23

Open alexey-sh opened 9 years ago

alexey-sh commented 9 years ago

Looks like gae limitation

Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/Users/alexey/projects/coolproject/main.py", line 35, in <module>
    @auto.doc()
  File "/Users/alexey/projects/coolproject/lib/flask_autodoc/autodoc.py", line 104, in decorator
    caller_frame = inspect.stack()[1]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 1055, in stack
    return getouterframes(sys._getframe(1), context)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 1033, in getouterframes
    framelist.append((frame,) + getframeinfo(frame, context))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 1008, in getframeinfo
    lines, lnum = findsource(frame)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 532, in findsource
    module = getmodule(object, file)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 504, in getmodule
    main = sys.modules['__main__']
KeyError: '__main__'
lukeyeager commented 9 years ago

Thanks for the bug report! This looks like a problem with #17.

Can you give me some example code to test with? I'm sure it will require choosing the location in the stack more intelligently than just inspect.stack()[1].

jwg4 commented 8 years ago

Possibly related: https://github.com/django-debug-toolbar/django-debug-toolbar/issues/279