2012-10-06 77 views
2

我遇到了Webapp2的問題。當我把處理程序指向不同的Python文件在app.yaml中我得到以下錯誤的網址:在多個文件中使用GAE Webapp2

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/[email protected]* 
    script: email.application 

- url: /.* 
    script: SDSUmodels.application 

libraries: 
- name: webapp2 
    version: "2.5.1" 

SDSUmodels.py結尾:

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

和email.py結尾

當我刪除這些行

- url: /send 
    script: email.application 

從app.yaml中,錯誤停止,但是這讓我沒有辦法向特定文件指向的URL。

我可以看到在this question中處理這個問題的一些替代方法,但我想知道爲什麼這種方法不起作用。我之前在舊版的webapp版本中完成了這項工作,並且已經開始工作 - 詳情如下。

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/[email protected]* 
    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() 
+1

已經有一個名爲['email'](http://docs.python.org/library/email.html)的stdlib庫;也許你需要重新命名以防止加載錯誤的庫? –

+0

歡迎來到Stack Overflow。感謝格式良好和詳細的問題。祝你好運! – bohney

+0

@MartijnPieters啊..我愚蠢。那樣做了。謝謝。 – ldbrooke

回答

3

有一個名爲email以及一個標準庫;它在您的本地模塊被找到之前被加載。

將模塊重命名爲其他東西,它會工作。