From 46353d75f7b9e3ed5aef70dc15e31fd192492a7a Mon Sep 17 00:00:00 2001 From: Casey Duncan Date: Sun, 28 Nov 2010 01:00:13 -0700 Subject: Add note about httpexceptions not typically being raised --- docs/narr/views.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'docs') diff --git a/docs/narr/views.rst b/docs/narr/views.rst index 956ef20e9..4b2207640 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -302,6 +302,19 @@ See :mod:`pyramid.httpexceptions` for the documentation for the ``HTTPFound`` exception; it also includes other response types that imply other HTTP response codes, such as ``HTTPUnauthorized`` for ``401 Unauthorized``. +.. note:: + + Although exception types from the :mod:`pyramid.httpexceptions` module are + in fact bona fide Python :class:`Exception` types, the :app:`Pyramid` view + machinery expects them to be *returned* by a view callable rather than + *raised*. + + It is possible, however, in Python 2.5 and above, to configure an + *exception view* to catch these exceptions, and return an appropriate + :class:`pyramid.response.Response`. The simplest such view could just + catch and return the original exception. See :ref:`exception_views` for + more details. + .. index:: single: renderer single: view renderer -- cgit v1.2.3