From d3e48e1afc209b7a73e73be76d8033c4ea9035cc Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 14 Sep 2010 14:00:49 +0000 Subject: - If an exception view was registered through the legacy ``set_notfound_view`` or ``set_forbidden_view`` APIs, the context sent to the view was incorrect (could be ``None`` inappropriately). --- CHANGES.txt | 10 ++++++++++ repoze/bfg/tests/test_view.py | 2 +- repoze/bfg/view.py | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 72b560e85..695aca255 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,16 @@ Next version ============ +Bug Fixes +--------- + +- If an exception view was registered through the legacy + ``set_notfound_view`` or ``set_forbidden_view`` APIs, the context + sent to the view was incorrect (could be ``None`` inappropriately). + +Errata +------ + - A prior changelog entry asserted that the ``INewResponse`` event was not sent to listeners if the response was not "valid" (if a view or renderer returned a response object that did not have a diff --git a/repoze/bfg/tests/test_view.py b/repoze/bfg/tests/test_view.py index 18a46a205..e5adc8de1 100644 --- a/repoze/bfg/tests/test_view.py +++ b/repoze/bfg/tests/test_view.py @@ -450,7 +450,7 @@ def make_view(response): return view class DummyRequest: - pass + exception = None class DummyResponse: status = '200 OK' diff --git a/repoze/bfg/view.py b/repoze/bfg/view.py index 2a154df87..c5fd60623 100644 --- a/repoze/bfg/view.py +++ b/repoze/bfg/view.py @@ -454,7 +454,7 @@ def default_exceptionresponse_view(context, request): # backwards compat for an exception response view registered via # config.set_notfound_view or config.set_forbidden_view # instead of as a proper exception view - context = getattr(request, 'exception', context) + context = request.exception or context return context class AppendSlashNotFoundViewFactory(object): @@ -502,7 +502,7 @@ class AppendSlashNotFoundViewFactory(object): if not isinstance(context, Exception): # backwards compat for an append_notslash_view registered via # config.set_notfound_view instead of as a proper exception view - context = getattr(request, 'exception', None) + context = request.exception path = request.environ.get('PATH_INFO', '/') registry = request.registry mapper = registry.queryUtility(IRoutesMapper) -- cgit v1.2.3