diff options
| author | Chris McDonough <chrism@plope.com> | 2011-06-20 00:57:30 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-06-20 00:57:30 -0400 |
| commit | f8f08bac0ea9edcac40fae2b3ad56e6a1ac7f47f (patch) | |
| tree | 3afd4c622f2dad1248fe20a35928a2c58e99af17 | |
| parent | d69ae60b9a195c7cb72122b59335ba886bfffe50 (diff) | |
| download | pyramid-f8f08bac0ea9edcac40fae2b3ad56e6a1ac7f47f.tar.gz pyramid-f8f08bac0ea9edcac40fae2b3ad56e6a1ac7f47f.tar.bz2 pyramid-f8f08bac0ea9edcac40fae2b3ad56e6a1ac7f47f.zip | |
responsecode -> exception_response
| -rw-r--r-- | CHANGES.txt | 10 | ||||
| -rw-r--r-- | docs/api/httpexceptions.rst | 2 | ||||
| -rw-r--r-- | docs/narr/views.rst | 19 | ||||
| -rw-r--r-- | docs/whatsnew-1.1.rst | 13 | ||||
| -rw-r--r-- | pyramid/httpexceptions.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_httpexceptions.py | 6 |
6 files changed, 27 insertions, 25 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 30001a7b5..ba392c7c6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -39,10 +39,10 @@ Documentation - Added API docs for ``pyramid.authentication.SessionAuthenticationPolicy``. -- Added API docs for ``pyramid.httpexceptions.responsecode``. +- Added API docs for ``pyramid.httpexceptions.exception_response``. - Added "HTTP Exceptions" section to Views narrative chapter including a - description of ``pyramid.httpexceptions.responsecode``. + description of ``pyramid.httpexceptions.exception_response``. Features -------- @@ -121,9 +121,9 @@ Features within view code; when raised, this exception view will render the exception to a response. -- A function named ``pyramid.httpexceptions.responsecode`` is a shortcut that - can be used to create HTTP exception response objects using an HTTP integer - status code. +- A function named ``pyramid.httpexceptions.exception_response`` is a + shortcut that can be used to create HTTP exception response objects using + an HTTP integer status code. - The Configurator now accepts an additional keyword argument named ``exceptionresponse_view``. By default, this argument is populated with a diff --git a/docs/api/httpexceptions.rst b/docs/api/httpexceptions.rst index 325d5af03..89be17a2d 100644 --- a/docs/api/httpexceptions.rst +++ b/docs/api/httpexceptions.rst @@ -11,7 +11,7 @@ integer "401" maps to :class:`pyramid.httpexceptions.HTTPUnauthorized`). - .. autofunction:: responsecode + .. autofunction:: exception_response .. autoclass:: HTTPException diff --git a/docs/narr/views.rst b/docs/narr/views.rst index e3d0a37e5..cbd8fcfb7 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -300,27 +300,30 @@ An HTTP exception, instead of being raised, can alternately be *returned* return HTTPUnauthorized() A shortcut for creating an HTTP exception is the -:func:`pyramid.httpexceptions.responsecode` function. This function accepts -an HTTP status code and returns the corresponding HTTP exception. For -example, instead of importing and constructing a +:func:`pyramid.httpexceptions.exception_response` function. This function +accepts an HTTP status code and returns the corresponding HTTP exception. +For example, instead of importing and constructing a :class:`~pyramid.httpexceptions.HTTPUnauthorized` response object, you can -use the :func:`~pyramid.httpexceptions.responsecode` function to construct -and return the same object. +use the :func:`~pyramid.httpexceptions.exception_response` function to +construct and return the same object. .. code-block:: python :linenos: - from pyramid.httpexceptions import responsecode + from pyramid.httpexceptions import exception_response def aview(request): - raise responsecode(401) + raise exception_response(401) This is the case because ``401`` is the HTTP status code for "HTTP -Unauthorized". Therefore, ``raise responsecode(401)`` is functionally +Unauthorized". Therefore, ``raise exception_response(401)`` is functionally equivalent to ``raise HTTPUnauthorized()``. Documentation which maps each HTTP response code to its purpose and its associated HTTP exception object is provided within :mod:`pyramid.httpexceptions`. +.. note:: The :func:`~pyramid.httpexceptions.exception_response` function is + new as of Pyramid 1.1. + How Pyramid Uses HTTP Exceptions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/whatsnew-1.1.rst b/docs/whatsnew-1.1.rst index 172a20343..cee701b49 100644 --- a/docs/whatsnew-1.1.rst +++ b/docs/whatsnew-1.1.rst @@ -18,8 +18,7 @@ The major feature additions in Pyramid 1.1 are: - Support for "static" routes. -- Default HTTP exception view and associated ``redirect`` and ``abort`` - convenience functions. +- Default HTTP exception view. ``request.response`` ~~~~~~~~~~~~~~~~~~~~ @@ -56,8 +55,8 @@ Static Routes Default HTTP Exception View ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- A default exception view for the context :exc:`webob.exc.HTTPException` - (aka :class:`pyramid.httpexceptions.HTTPException`) is now registered by +- A default exception view for the context + :class:`pyramid.interfaces.IExceptionResponse` is now registered by default. This means that an instance of any exception class imported from :mod:`pyramid.httpexceptions` (such as ``HTTPFound``) can now be raised from within view code; when raised, this exception view will render the @@ -79,9 +78,9 @@ Minor Feature Additions :class:`pyramid.authentication.SessionAuthenticationPolicy`, which uses a session to store credentials. -- A function named :func:`pyramid.httpexceptions.responsecode` is a shortcut - that can be used to create HTTP exception response objects using an HTTP - integer status code. +- A function named :func:`pyramid.httpexceptions.exception_response` is a + shortcut that can be used to create HTTP exception response objects using + an HTTP integer status code. - Integers and longs passed as ``elements`` to :func:`pyramid.url.resource_url` or diff --git a/pyramid/httpexceptions.py b/pyramid/httpexceptions.py index b86e4badf..44b854929 100644 --- a/pyramid/httpexceptions.py +++ b/pyramid/httpexceptions.py @@ -978,7 +978,7 @@ class HTTPInsufficientStorage(HTTPServerError): title = 'Insufficient Storage' explanation = ('There was not enough space to save the resource') -def responsecode(status_code, **kw): +def exception_response(status_code, **kw): """Creates an HTTP exception based on a status code. Example:: raise responsecode(404) # raises an HTTPNotFound exception. diff --git a/pyramid/tests/test_httpexceptions.py b/pyramid/tests/test_httpexceptions.py index 705b988e6..203d442f7 100644 --- a/pyramid/tests/test_httpexceptions.py +++ b/pyramid/tests/test_httpexceptions.py @@ -1,9 +1,9 @@ import unittest -class Test_responsecode(unittest.TestCase): +class Test_exception_response(unittest.TestCase): def _callFUT(self, *arg, **kw): - from pyramid.httpexceptions import responsecode - return responsecode(*arg, **kw) + from pyramid.httpexceptions import exception_response + return exception_response(*arg, **kw) def test_status_404(self): from pyramid.httpexceptions import HTTPNotFound |
