Permalink
Browse files

- 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.
  • Loading branch information...
1 parent 356d032 commit 966b5cfe03009069d7bbe92cc047b32a5e3cd4e6 @mcdonc mcdonc committed May 30, 2011
Showing with 47 additions and 24 deletions.
  1. +25 −12 CHANGES.txt
  2. +5 −2 pyramid/__init__.py
  3. +7 −6 pyramid/config.py
  4. +2 −2 pyramid/exceptions.py
  5. +8 −2 pyramid/response.py
View
37 CHANGES.txt
@@ -104,12 +104,13 @@ Features
section entitled "Static Routes" in the URL Dispatch narrative chapter for
more information.
-- A default exception view for the context ``webob.exc.HTTPException`` (aka
- ``pyramid.httpexceptions.HTTPException``) is now registered by default.
- This means that an instance of any exception class imported from
- ``pyramid.httpexceptions`` (such as ``HTTPFound``) can now be raised from
- within view code; when raised, this exception view will render the
- exception to a response.
+- A default exception view for the context
+ ``pyramid.interfaces.IExceptionResponse`` (aka
+ ``pyramid.response.Response`` or ``pyramid.httpexceptions.HTTPException``)
+ is now registered by default. This means that an instance of any exception
+ response class imported from ``pyramid.httpexceptions`` (such as
+ ``HTTPFound``) can now be raised from within view code; when raised, this
+ exception view will render the exception to a response.
- New functions named ``pyramid.httpexceptions.abort`` and
``pyramid.httpexceptions.redirect`` perform the equivalent of their Pylons
@@ -118,12 +119,18 @@ Features
``webob.exc.HTTPException``.
- The Configurator now accepts an additional keyword argument named
- ``httpexception_view``. By default, this argument is populated with a
- default exception view function that will be used when an HTTP exception is
- raised. When ``None`` is passed for this value, an exception view for HTTP
- exceptions will not be registered. Passing ``None`` returns the behavior
- of raising an HTTP exception to that of Pyramid 1.0 (the exception will
- propagate to middleware and to the WSGI server).
+ ``exceptionresponse_view``. By default, this argument is populated with a
+ default exception view function that will be used when a response is raised
+ as an exception. When ``None`` is passed for this value, an exception view
+ for responses will not be registered. Passing ``None`` returns the
+ behavior of raising an HTTP exception to that of Pyramid 1.0 (the exception
+ will propagate to middleware and to the WSGI server).
+
+- 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``.
Bug Fixes
---------
@@ -289,6 +296,12 @@ Behavior Changes
implements its own ``__getattr__``, ``__setattr__`` or ``__delattr__`` as a
result.
+- ``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.
+
Dependencies
------------
View
7 pyramid/__init__.py
@@ -1,2 +1,5 @@
-# pyramid package
-
+from pyramid.request import Request
+from pyramid.response import Response
+Response.RequestClass = Request
+Request.ResponseClass = Response
+del Request, Response
View
13 pyramid/config.py
@@ -260,12 +260,13 @@ class or a :term:`dotted Python name` to same. The debug logger
If ``exceptionresponse_view`` is passed, it must be a :term:`view
callable` or ``None``. If it is a view callable, it will be used as an
exception view callable when an :term:`exception response` is raised (any
- named exception from the ``pyramid.exceptions`` module that begins with
- ``HTTP`` as well as the ``NotFound`` and ``Forbidden`` exceptions) as
- well as exceptions raised via :func:`pyramid.exceptions.abort`,
- :func:`pyramid.exceptions.redirect`. If ``exceptionresponse_view`` is
- ``None``, no exception response view will be registered, and all
- raised exception responses will be bubbled up to Pyramid's caller. By
+ object that implements the :class:`pyramid.interaces.IExceptionResponse`
+ interface, such as a :class:`pyramid.response.Response` object or any
+ ``HTTP`` exception documented in :mod:`pyramid.httpexceptions` as well as
+ exception responses raised via :func:`pyramid.exceptions.abort`,
+ :func:`pyramid.exceptions.redirect`). If ``exceptionresponse_view`` is
+ ``None``, no exception response view will be registered, and all raised
+ exception responses will be bubbled up to Pyramid's caller. By
default, the ``pyramid.exceptions.default_exceptionresponse_view``
function is used as the ``exceptionresponse_view``. This argument is new
in Pyramid 1.1. """
View
4 pyramid/exceptions.py
@@ -128,7 +128,8 @@ def _no_escape(value):
value = str(value)
return value
-class HTTPException(Exception):
+
+class HTTPException(Exception): # bw compat
pass
class WSGIHTTPException(Response, HTTPException):
@@ -1040,7 +1041,6 @@ 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
- # WSGIHTTPException, a Response (2.5+)
return context
status_map={}
View
10 pyramid/response.py
@@ -1,2 +1,8 @@
-from webob import Response
-Response = Response # pyflakes
+from webob import Response as _Response
+from zope.interface import implements
+
+from pyramid.interfaces import IExceptionResponse
+
+class Response(_Response, Exception):
+ implements(IExceptionResponse)
+

0 comments on commit 966b5cf

Please sign in to comment.