Commit 4f0f50c6 authored by Hanno Schlichting's avatar Hanno Schlichting

Add `egg:Zope2#httpexceptions` WSGI middleware, refs #64.

This serves the same purpose as `egg:paste#httpexceptions`, but
recognizes exceptions derived from `zExceptions.HTTPException`.
parent 10a5689c
......@@ -51,6 +51,8 @@ Bugs Fixed
Features Added
++++++++++++++
- Add `egg:Zope2#httpexceptions` WSGI middleware.
- Update available HTTP response code, 302 is now called Found.
- Add a new `runwsgi` script to serve PasteDeploy files.
......
......@@ -122,6 +122,9 @@ setup(
'paste.app_factory': [
'main=Zope2.Startup.run:make_wsgi_app',
],
'paste.filter_app_factory': [
'httpexceptions=Zope2.Startup.httpexceptions:main',
],
'console_scripts': [
'mkzopeinstance=Zope2.utilities.mkzopeinstance:main',
'runwsgi=Zope2.Startup.serve:main',
......
from zExceptions import HTTPException
class HTTPExceptionHandler(object):
def __init__(self, application):
self.application = application
def __call__(self, environ, start_response):
environ['Zope2.httpexceptions'] = self
try:
return self.application(environ, start_response)
except HTTPException as exc:
return exc(environ, start_response)
def main(app, global_conf=None):
return HTTPExceptionHandler(app)
......@@ -4,7 +4,7 @@ zope_conf = %(here)s/wsgi.conf
[pipeline:main]
pipeline =
egg:paste#httpexceptions
egg:Zope2#httpexceptions
egg:repoze.retry#retry
egg:repoze.tm2#tm
zope
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment