- Register the default exception view for context of
webob.exc.WSGIHTTPException (convenience).
- Use ``exc.message`` in docs rather than ``exc.args[0]`` now that
we control this.
| | |
| | | Must-Have |
| | | --------- |
| | | |
| | | - Grep for IExceptionResponse, forgot what it does. |
| | | |
| | | - Docs mention ``exception.args[0]`` as a way to get messages; check that |
| | | this works. |
| | | |
| | | - Deprecate response_foo attrs on request at attribute set time rather than |
| | | lookup time. |
| | | |
| | |
| | | :term:`request`. The ``exception`` attribute of the request will be an |
| | | instance of the :exc:`~pyramid.httpexceptions.HTTPNotFound` exception that |
| | | caused the not found view to be called. The value of |
| | | ``request.exception.args[0]`` will be a value explaining why the not found |
| | | ``request.exception.message`` will be a value explaining why the not found |
| | | error was raised. This message will be different when the |
| | | ``debug_notfound`` environment setting is true than it is when it is |
| | | false. |
| | |
| | | :term:`request`. The ``exception`` attribute of the request will be an |
| | | instance of the :exc:`~pyramid.httpexceptions.HTTPForbidden` exception |
| | | that caused the forbidden view to be called. The value of |
| | | ``request.exception.args[0]`` will be a value explaining why the forbidden |
| | | was raised. This message will be different when the |
| | | ``request.exception.message`` will be a value explaining why the forbidden |
| | | was raised and ``request.exception.result`` will be extended information |
| | | about the forbidden exception. These messages will be different when the |
| | | ``debug_authorization`` environment setting is true than it is when it is |
| | | false. |
| | | |
| | |
| | | self._set_root_factory(root_factory) |
| | | # cope with WebOb response objects that aren't decorated with IResponse |
| | | from webob import Response as WebobResponse |
| | | # cope with WebOb exc objects not decoratored with IExceptionResponse |
| | | from webob.exc import WSGIHTTPException as WebobWSGIHTTPException |
| | | registry.registerSelfAdapter((WebobResponse,), IResponse) |
| | | debug_logger = self.maybe_dotted(debug_logger) |
| | | if debug_logger is None: |
| | |
| | | if exceptionresponse_view is not None: |
| | | exceptionresponse_view = self.maybe_dotted(exceptionresponse_view) |
| | | self.add_view(exceptionresponse_view, context=IExceptionResponse) |
| | | self.add_view(exceptionresponse_view,context=WebobWSGIHTTPException) |
| | | if locale_negotiator: |
| | | locale_negotiator = self.maybe_dotted(locale_negotiator) |
| | | registry.registerUtility(locale_negotiator, ILocaleNegotiator) |
| | |
| | | # config.set_notfound_view or config.set_forbidden_view |
| | | # instead of as a proper exception view |
| | | context = request.exception or context |
| | | return context |
| | | return context # assumed to be an IResponse |
| | | |
| | | status_map={} |
| | | code = None |
| | |
| | | self.assertEqual(reg.has_listeners, True) |
| | | |
| | | def test_setup_registry_registers_default_exceptionresponse_view(self): |
| | | from webob.exc import WSGIHTTPException |
| | | from pyramid.interfaces import IExceptionResponse |
| | | from pyramid.view import default_exceptionresponse_view |
| | | reg = DummyRegistry() |
| | |
| | | config.setup_registry() |
| | | self.assertEqual(views[0], ((default_exceptionresponse_view,), |
| | | {'context':IExceptionResponse})) |
| | | self.assertEqual(views[1], ((default_exceptionresponse_view,), |
| | | {'context':WSGIHTTPException})) |
| | | |
| | | def test_setup_registry_registers_default_webob_iresponse_adapter(self): |
| | | from webob import Response |