2

我在使用 Webapp2 时遇到问题。当我在 app.yaml 中放置指向不同 python 文件的 URL 的处理程序时,我收到以下错误:

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

我的 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 以:

application = webapp2.WSGIApplication([('/info', MakeBasicInfo)], 
                                   debug=True)`

并且 email.py 以:

application = webapp2.WSGIApplication([('/request', Request_update),
                                   ('/send', Send_report),
                                   (Receive_email.mapping())], 
                                   debug=True)`

当我删除这些行

- url: /send
  script: email.application

从 app.yaml 中,错误停止了,但这让我无法将 URL 指向特定文件。

我可以在这个问题中看到一些处理这个问题的替代方法,但我想知道为什么这种方法不起作用。我之前在另一个项目中使用旧的 webapp 版本完成了此操作,并且可以正常工作 - 详细信息如下。

应用程序.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 以:

application = webapp.WSGIApplication(
                                     [('/twitter', Process_new_DM)],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
4

1 回答 1

3

还有一个名为的标准库email;它是在找到本地模块之前加载的。

将模块重命名为其他名称,它将起作用。

于 2012-10-06T17:21:38.913 回答