diff options
author | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2012-12-23 11:57:45 +0100 |
---|---|---|
committer | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2012-12-23 11:57:45 +0100 |
commit | 785b287fcb42ac9130b222006097e3f68cec3543 (patch) | |
tree | 686f11a1bcb951af8150292f92a404d16dac7907 /api-docs/source/modules.rst | |
parent | 511d5b89664daef455da0579e8c8658e5b81cce5 (diff) | |
download | mediagoblin-785b287fcb42ac9130b222006097e3f68cec3543.tar.lz mediagoblin-785b287fcb42ac9130b222006097e3f68cec3543.tar.xz mediagoblin-785b287fcb42ac9130b222006097e3f68cec3543.zip |
Provide tools.response.render_http_exception and use that
After the webob->werkzeug transition, controller functions can raise
werkzeug.HttpExceptions. We need to catch these in app.py when calling
the controller and handle them, rendering the corresponding error Response()
object. For consistency, we also want to allow meddleware functions to
raise HttpExceptions (e.g. the csrf meddleware needs to complain about lack
of cookies), so wrap the request and response parts of the meddleware too.
Finally, the urlmap.match() can also raise HttpExceptions, so we give it the
same treatment (render_http_exception). I am not sure, if we do not need to
handle the Redirect exception there in any different way though...
The new function render_http_exception makes use of the render_error infrastructure
to return a nicely templated error page. It also checks if the stock error
messages was used in cases where we have localizations (403, 404) and use those.
It is now possible to do things like "raise Forbidden(_('You suckr'))" or
raise NotFound(_('where is my left show again')) if you want to return
customized error messages to the user.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Diffstat (limited to 'api-docs/source/modules.rst')
0 files changed, 0 insertions, 0 deletions