diff options
| -rw-r--r-- | CHANGES.txt | 11 | ||||
| -rw-r--r-- | docs/api/exceptions.rst | 1 | ||||
| -rw-r--r-- | repoze/bfg/exceptions.py | 26 | ||||
| -rw-r--r-- | repoze/bfg/router.py | 3 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_router.py | 25 |
5 files changed, 1 insertions, 65 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 0f6818e3c..98ec6d08f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,12 +14,6 @@ Features registration of "settings" values obtained via ``repoze.bfg.settings.get_settings()`` for use in unit tests. -- A new exception exists: ``repoze.bfg.exceptions.Respond``. This - exception can be raised during view execution return a response. - This is effectively a goto, useable by code that has no capability - to otherwise return a response. It is documented in the - ``repoze.bfg.exceptions`` API documentation. - - The name ``root`` is available as an attribute of the request slightly earlier now (before a NewRequest event is emitted). ``root`` is the result of the application "root factory". @@ -33,11 +27,6 @@ Features Bug Fixes --------- -- Re-issue authentication ticket if the cookie has expired when using - ``repoze.bfg.security.remember`` when the - ``authtktauthenticationpolicy`` authentication policy is in effect. - (Patch from Andreas Zeidler). - - Fix bug encountered during "scan" (when ``<scan ..>`` directive is used in ZCML) introduced in 1.1a7. Symptom: ``AttributeError: object has no attribute __provides__`` raised at startup time. diff --git a/docs/api/exceptions.rst b/docs/api/exceptions.rst index 67ca085f4..ecd85fc96 100644 --- a/docs/api/exceptions.rst +++ b/docs/api/exceptions.rst @@ -9,4 +9,3 @@ .. autoclass:: NotFound - .. autoclass:: Respond diff --git a/repoze/bfg/exceptions.py b/repoze/bfg/exceptions.py index bc05fa699..afd617a2c 100644 --- a/repoze/bfg/exceptions.py +++ b/repoze/bfg/exceptions.py @@ -22,29 +22,3 @@ class NotFound(Exception): into the WSGI environment under the ``repoze.bfg.message`` key, for availability to the Not Found view.""" -class Respond(Exception): - """\ - Raise this exception during view execution to return a response - immediately without proceeeding any further through the codepath. - Use of this exception is effectively a 'goto': its target is the - exception handler within the :mod:`repoze.bfg' router that catches - the exception and returns a response immediately. Note that - because this exception is caught by the router, it will not - propagate to any WSGI middleware. Note that this exception is - typically only used by the framework itself and by authentication - plugins to the framework. - - The exception must be initialized which a single argument, which - is a :term:`response` object. - - An example: - - .. code-block:: python - :linenos: - - from webob.exc import HTTPFound - from repoze.bfg.exceptions import Respond - response = HTTPFound(location='http://example.com') - raise Respond(response) - """ - diff --git a/repoze/bfg/router.py b/repoze/bfg/router.py index 03f93857c..41b8ee553 100644 --- a/repoze/bfg/router.py +++ b/repoze/bfg/router.py @@ -19,7 +19,6 @@ from repoze.bfg.events import NewResponse from repoze.bfg.events import WSGIApplicationCreatedEvent from repoze.bfg.exceptions import Forbidden from repoze.bfg.exceptions import NotFound -from repoze.bfg.exceptions import Respond from repoze.bfg.request import request_factory from repoze.bfg.threadlocal import manager from repoze.bfg.traversal import ModelGraphTraverser @@ -115,8 +114,6 @@ class Router(object): msg = why[0] environ['repoze.bfg.message'] = msg response = self.notfound_view(context, request) - except Respond, why: - response = why[0] registry.has_listeners and registry.notify(NewResponse(response)) diff --git a/repoze/bfg/tests/test_router.py b/repoze/bfg/tests/test_router.py index 9306640b4..50a763688 100644 --- a/repoze/bfg/tests/test_router.py +++ b/repoze/bfg/tests/test_router.py @@ -372,25 +372,6 @@ class TestRouter(unittest.TestCase): self.assertEqual(start_response.status, '404 Not Found') self.assertEqual(environ['repoze.bfg.message'], 'notfound') - def test_call_view_raises_respond(self): - from zope.interface import Interface - from zope.interface import directlyProvides - class IContext(Interface): - pass - from repoze.bfg.interfaces import IRequest - context = DummyContext() - directlyProvides(context, IContext) - self._registerTraverserFactory(context, subpath=['']) - response = DummyResponse('200 OK') - raised = DummyResponse('201 Created') - view = DummyView(response, raise_respond=raised) - environ = self._makeEnviron() - self._registerView(view, '', IContext, IRequest) - router = self._makeOne() - start_response = DummyStartResponse() - response = router(environ, start_response) - self.assertEqual(start_response.status, '201 Created') - def test_call_request_has_global_response_headers(self): from zope.interface import Interface from zope.interface import directlyProvides @@ -506,11 +487,10 @@ class DummyContext: class DummyView: def __init__(self, response, raise_unauthorized=False, - raise_notfound=False, raise_respond=False): + raise_notfound=False): self.response = response self.raise_unauthorized = raise_unauthorized self.raise_notfound = raise_notfound - self.raise_respond = raise_respond def __call__(self, context, request): if self.raise_unauthorized: @@ -519,9 +499,6 @@ class DummyView: if self.raise_notfound: from repoze.bfg.exceptions import NotFound raise NotFound('notfound') - if self.raise_respond: - from repoze.bfg.exceptions import Respond - raise Respond(self.raise_respond) return self.response class DummyRootFactory: |
