8000 - Fix older CHANGES entries. · alex-python/pyramid@966b5cf · GitHub
[go: up one dir, main page]

Skip to content

Commit 966b5cf

Browse files
committed
- Fix older CHANGES entries.
- The ``pyramid.request.Request`` class now has a ``ResponseClass`` interface which points at ``pyramid.response.Response``. - The ``pyramid.request.Response`` class now has a ``RequestClass`` interface which points at ``pyramid.response.Request``. - ``pyramid.response.Response`` is now a *subclass* of ``webob.response.Response``. It also inherits from the built-in Python ``Exception`` class and implements the ``pyramid.interfaces.IExceptionResponse`` class so it can be raised as an exception from view code.
1 parent 356d032 commit 966b5cf

File tree

5 files changed

+47
-24
lines changed

5 files changed

+47
-24
lines changed

CHANGES.txt

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,13 @@ Features
104104
section entitled "Static Routes" in the URL Dispatch narrative chapter for
105105
more information.
106106

107-
- A default exception view for the context ``webob.exc.HTTPException`` (aka
108-
``pyramid.httpexceptions.HTTPException``) is now registered by default.
109-
This means that an instance of any exception class imported from
110-
``pyramid.httpexceptions`` (such as ``HTTPFound``) can now be raised from
111-
within view code; when raised, this exception view will render the
112-
exception to a response.
107+
- A default exception view for the context
108+
``pyramid.interfaces.IExceptionResponse`` (aka
109+
``pyramid.response.Response`` or ``pyramid.httpexceptions.HTTPException``)
110+
is now registered by default. This means that an instance of any exception
111+
response class imported from ``pyramid.httpexceptions`` (such as
112+
``HTTPFound``) can now be raised from within view code; when raised, this
113+
exception view will render the exception to a response.
113114

114115
- New functions named ``pyramid.httpexceptions.abort`` and
115116
``pyramid.httpexceptions.redirect`` perform the equivalent of their Pylons
@@ -118,12 +119,18 @@ Features
118119
``webob.exc.HTTPException``.
119120

120121
- The Configurator now accepts an additional keyword argument named
121-
``httpexception_view``. By default, this argument is populated with a
122-
default exception view function that will be used when an HTTP exception is
123-
raised. When ``None`` is passed for this value, an exception view for HTTP
124-
exceptions will not be registered. Passing ``None`` returns the behavior
125-
of raising an HTTP exception to that of Pyramid 1.0 (the exception will
126-
propagate to middleware and to the WSGI server).
122+
``exceptionresponse_view``. By default, this argument is populated with a
123+
default exception view function that will be used when a response is raised
124+
as an exception. When ``None`` is passed for this value, an exception view
125+
for responses will not be registered. Passing ``None`` returns the
126+
behavior of raising an HTTP exception to that of Pyramid 1.0 (the exception
127+
will propagate to middleware and to the WSGI server).
128+
129+
- The ``pyramid.request.Request`` class now has a ``ResponseClass`` interface
130+
which points at ``pyramid.response.Response``.
131+
132+
- The ``pyramid.request.Response`` class now has a ``RequestClass`` interface
133+
which points at ``pyramid.response.Request``.
127134

128135
Bug Fixes
129136
---------
@@ -289,6 +296,12 @@ Behavior Changes
289296
implements its own ``__getattr__``, ``__setattr__`` or ``__delattr__`` as a
290297
result.
291298

299+
- ``pyramid.response.Response`` is now a *subclass* of
300+
``webob.response.Response``. It also inherits from the built-in Python
301+
``Exception`` class and implements the
302+
``pyramid.interfaces.IExceptionResponse`` class so it can be raised as an
303+
exception from view code.
304+
292305
Dependencies
293306
------------
294307

pyramid/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# pyramid package
2-
1+
from pyramid.request import Request
2+
from pyramid.response import Response
3+
Response.RequestClass = Request
4+
Request.ResponseClass = Response
5+
del Request, Response

pyramid/config.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,13 @@ class or a :term:`dotted Python name` to same. The debug logger
260260
If ``exceptionresponse_view`` is passed, it must be a :term:`view
261261
callable` or ``None``. If it is a view callable, it will be used as an
262262
exception view callable when an :term:`exception response` is raised (any
263-
named exception from the ``pyramid.exceptions`` module that begins with
264-
``HTTP`` as well as the ``NotFound`` and ``Forbidden`` exceptions) as
265-
well as exceptions raised via :func:`pyramid.exceptions.abort`,
266-
:func:`pyramid.exceptions.redirect`. If ``exceptionresponse_view`` is
267-
``None``, no exception response view will be registered, and all
268-
raised exception responses will be bubbled up to Pyramid's caller. By
263+
object that implements the :class:`pyramid.interaces.IExceptionResponse`
264+
interface, such as a :class:`pyramid.response.Response` object or any
265+
``HTTP`` exception documented in :mod:`pyramid.httpexceptions` as well as
266+
exception responses raised via :func:`pyramid.exceptions.abort`,
267+
:func:`pyramid.exceptions.redirect`). If ``exceptionresponse_view`` is
268+
``None``, no exception response view will be registered, and all raised
269+
exception responses will be bubbled up to Pyramid's caller. By
269270
default, the ``pyramid.exceptions.default_exceptionresponse_view``
270271
function is used as the ``exceptionresponse_view``. This argument is new
271272
in Pyramid 1.1. """

pyramid/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ def _no_escape(value):
128128
value = str(value)
129129
return value
130130

131-
class HTTPException(Exception):
131+
132+
class HTTPException(Exception): # bw compat
132133
pass
133134

134135
class WSGIHTTPException(Response, HTTPException):
@@ -1040,7 +1041,6 @@ def default_exceptionresponse_view(context, request):
10401041
# config.set_notfound_view or config.set_forbidden_view
10411042
# instead of as a proper exception view
10421043
context = request.exception or context
1043-
# WSGIHTTPException, a Response (2.5+)
10441044
return context
10451045

10461046
status_map={}

pyramid/response.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
from webob import Response
2-
Response = Response # pyflakes
1+
from webob import Response as _Response
2+
from zope.interface import implements
3+
4+
from pyramid.interfaces import IExceptionResponse
5+
6+
class Response(_Response, Exception):
7+
implements(IExceptionResponse)
8+

0 commit comments

Comments
 (0)
0