【问题标题】:Running web2py as a WSGI app on GAE with Python2.7使用 Python2.7 在 GAE 上将 web2py 作为 WSGI 应用程序运行
【发布时间】:2012-03-27 12:48:56
【问题描述】:

如何设置Web2Py [Version 1.99.4 (2011-12-14 14:46:14) stable] 以在GAEPython2.7.2 上作为WSGI 应用程序运行?

目前,我的app.yaml 文件如下所示:

#  For Google App Engine deployment, copy this file to app.yaml
#  and edit as required
#  See http://code.google.com/appengine/docs/python/config/appconfig.html
#  and http://web2py.com/book/default/chapter/11?search=app.yaml

application: my-app-name
version: 1
api_version: 1

# use this line for Python 2.5
#
# runtime: python

# use these lines for Python 2.7
# upload app with: appcfg.py update web2py (where 'web2py' is web2py's root directory)

runtime: python27
threadsafe: true
# true for WSGI & concurrent requests (Python 2.7 only)

default_expiration: "24h"   
# for static files

handlers:

- url: /(?P<a>.+?)/static/(?P<b>.+)
  static_files: applications/\1/static/\2
  upload: applications/(.+?)/static/(.+)
  secure: optional

- url: /favicon.ico
  static_files: applications/welcome/static/favicon.ico
  upload: applications/welcome/static/favicon.ico

- url: /robots.txt
  static_files: applications/welcome/static/robots.txt
  upload: applications/welcome/static/robots.txt

- url: .*
  script: gaehandler.py         
  # CGI
#  script: gaehandler.wsgiapp    # WSGI (Python 2.7 only)
  secure: optional

admin_console:
  pages:
  - name: Appstats
    url: /_ah/stats

skip_files: |
 ^(.*/)?(
 (app\.yaml)|
 (app\.yml)|
 (index\.yaml)|
 (index\.yml)|
 (#.*#)|
 (.*~)|
 (.*\.py[co])|
 (.*/RCS/.*)|
 (\..*)|
 (applications/(admin|examples|welcome)/.*)|
 ((admin|examples|welcome)\.(w2p|tar))|
 (applications/.*?/(cron|databases|errors|cache|sessions)/.*)|
 ((logs|scripts)/.*)|
 (anyserver\.py)|
 (web2py\.py)|
 ((cgi|fcgi|modpython|wsgi)handler\.py)|
 (epydoc\.(conf|css))|
 (httpserver\.log)|
 (logging\.example\.conf)|
 (route[rs]\.example\.py)|
 (setup_(app|exe)\.py)|
 (splashlogo\.gif)|
 (parameters_\d+\.py)|
 (options_std.py)|
 (gluon/tests/.*)|
 (gluon/(rocket|winservice)\.py)|
 (contrib/(gateways|markdown|memcache|pymysql)/.*)|
 (contrib/(populate|taskbar_widget)\.py)|
 (google_appengine/.*)|
 (.*\.(bak|orig))|
 )$

builtins:
- remote_api: on
- datastore_admin: on
- appstats: on
- admin_redirect: on
- deferred: on

但尝试使用AppEngine SDK for Python (v1.6.3) 加载应用程序时出现以下错误:

2012-03-10 12:37:01 Running command: "[u'C:\\Python27\\pythonw.exe', 'C:\\Program Files\\Google\\google_appengine\\dev_appserver.py', '--admin_console_server=', '--port=8088', u'E:\\Programming\\Python\\web2py']"
WARNING  2012-03-10 07:07:18,851 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.
ERROR    2012-03-10 07:07:20,483 dev_appserver_main.py:581] Fatal error when loading application configuration:
Invalid object:
threadsafe cannot be enabled with CGI handler: gaehandler.py
  in "E:\Programming\Python\web2py\app.yaml", line 90, column 1
2012-03-10 12:37:20 (Process exited with code 1)

另外,鉴于我是新手,关于threadsafe WSGI 应用程序还有什么我应该知道的吗?我是否需要对我的应用进行任何更改才能将其作为一个整体运行?

【问题讨论】:

    标签: google-app-engine thread-safety wsgi python-2.7 web2py


    【解决方案1】:

    注释掉 gaehandler.py 行并取消注释 gaehandler.wsgiapp 行。

    【讨论】:

    • 另外,你应该禁用 datastore_admin 内置,因为它在 python27 下不受支持。
    猜你喜欢
    • 2011-06-02
    • 2012-05-08
    • 1970-01-01
    • 2023-04-10
    • 2020-04-08
    • 1970-01-01
    • 1970-01-01
    • 2012-04-14
    • 1970-01-01
    相关资源
    最近更新 更多