I’m having problems with Webapp2. When I put handlers for URLs that point to different python files in the app.yaml I get the following error:
ERROR 2012-10-06 16:44:57,759 wsgi.py:203]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 195, 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 250, in _LoadHandler
__import__(cumulative_path)
ImportError: No module named application
My app.yaml:
application: [[app's name]]
version: 1
runtime: python27
api_version: 1
threadsafe: yes
inbound_services:
- mail
handlers:
- url: /send
script: email.application
- url: /_ah/mail/update@sitdown-standup.appspotmail.com.*
script: email.application
- url: /.*
script: SDSUmodels.application
libraries:
- name: webapp2
version: "2.5.1"
SDSUmodels.py ends with:
application = webapp2.WSGIApplication([('/info', MakeBasicInfo)],
debug=True)`
and email.py ends with:
application = webapp2.WSGIApplication([('/request', Request_update),
('/send', Send_report),
(Receive_email.mapping())],
debug=True)`
When I remove these lines
- url: /send
script: email.application
from app.yaml, the error stops, but this leaves me without a way to point a URL towards a particular file.
I can see some alternative ways of handling this in this question but I was wondering why this approach isn’t working. I’ve done this previously with the old webapp version in a different project and it’s worked – details below.
app.yaml:
application: [[other app's name]]
version: 1
runtime: python
api_version: 1
handlers:
- url: /stylesheets
static_dir: stylesheets
- url: /twitter
script: twitter.py
- url: /_ah/mail/kindle@shelvdtracker.appspotmail.com.*
script: kindle.py
- url: /.*
script: web.py
inbound_services:
- mail
twitter.py ends with:
application = webapp.WSGIApplication(
[('/twitter', Process_new_DM)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
There is a standard library named
emailas well; it is being loaded before your local module is being found.Rename the module to something else and it’ll work.