-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
egg:Zope2#httpexceptions
WSGI middleware, refs #64.
This serves the same purpose as `egg:paste#httpexceptions`, but recognizes exceptions derived from `zExceptions.HTTPException`.
- Loading branch information
Showing
4 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters