2

我们正在尝试设置 gunicorn + plone。到目前为止它运行良好,但无法处理错误(404、500 等)并抛出“内部服务器错误”,而它应该返回 plone 的错误页面。

下面粘贴了请求一个不存在的页面的示例。问题是应该如何设置 gunicorn,以便 zope/plone 自己处理错误,就像其他请求一样?

欢呼和问候

==> var/log/gunicorn-stdout---supervisor-JhaTfg.log <==
2012-05-24 01:41:16 [15137] [ERROR] Error handling request
Traceback (most recent call last):
  File "/home/user/testing/eggs/gunicorn-0.14.3-py2.6.egg/gunicorn/workers/sync.py", line 100, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/home/user/testing/eggs/repoze.retry-1.0-py2.6.egg/repoze/retry/__init__.py", line 90, in __call__
    app_iter = self.application(environ, replace_start_response)
  File "/home/user/testing/eggs/repoze.tm2-1.0b2-py2.6.egg/repoze/tm/__init__.py", line 24, in __call__
    result = self.application(environ, save_status_and_headers)
  File "/home/user/testing/eggs/repoze.vhm-0.14-py2.6.egg/repoze/vhm/middleware.py", line 106, in __call__
    return self.application(environ, start_response)
  File "/home/user/testing/eggs/Zope2-2.13.13-py2.6.egg/ZPublisher/WSGIPublisher.py", line 255, in publish_module
    response = _publish(request, 'Zope2')
  File "/home/user/testing/eggs/Zope2-2.13.13-py2.6.egg/ZPublisher/WSGIPublisher.py", line 185, in publish
    object = request.traverse(path, validated_hook=validated_hook)
  File "/home/user/testing/eggs/Zope2-2.13.13-py2.6.egg/ZPublisher/BaseRequest.py", line 518, in traverse
    return response.notFoundError(URL)
  File "/home/user/testing/eggs/Zope2-2.13.13-py2.6.egg/ZPublisher/HTTPResponse.py", line 718, in notFoundError
    "<p><b>Resource:</b> %s</p>" % escape(entry))
NotFound:   <h2>Site Error</h2>
  <p>An error was encountered while publishing this resource.
  </p>
4

1 回答 1

0

关于我的问题,我忘了提到我们正在使用 WSGI Zope 和 gunicorn。

在我们的场景中,我们修补了 ZPublisher/WSGIPublisher.py 以正确处理 NotFound 异常 (404),而不是抛出 500 Internal Server Error。

结果表明 Zope + Wsgi 还没有那么成熟(至少在错误处理方面)。

于 2012-05-31T19:40:06.730 回答