diff options
| -rw-r--r-- | TODO.txt | 5 | ||||
| -rw-r--r-- | docs/narr/hooks.rst | 7 | ||||
| -rw-r--r-- | pyramid/config.py | 3 | ||||
| -rw-r--r-- | pyramid/httpexceptions.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_config.py | 3 |
5 files changed, 11 insertions, 9 deletions
@@ -4,11 +4,6 @@ Pyramid TODOs 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. diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index e5b85dfbf..1c8a64fd7 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -59,7 +59,7 @@ Here's some sample code that implements a minimal NotFound view callable: :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. @@ -125,8 +125,9 @@ Here's some sample code that implements a minimal forbidden view: :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. diff --git a/pyramid/config.py b/pyramid/config.py index 70b5cd639..1e4cbb350 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -713,6 +713,8 @@ class Configurator(object): 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: @@ -726,6 +728,7 @@ class Configurator(object): 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) diff --git a/pyramid/httpexceptions.py b/pyramid/httpexceptions.py index 68c40b098..b86e4badf 100644 --- a/pyramid/httpexceptions.py +++ b/pyramid/httpexceptions.py @@ -994,7 +994,7 @@ def default_exceptionresponse_view(context, request): # 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 diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index 2e223076d..12146895d 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -339,6 +339,7 @@ class ConfiguratorTests(unittest.TestCase): 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() @@ -348,6 +349,8 @@ class ConfiguratorTests(unittest.TestCase): 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 |
