diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-09-14 14:00:49 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-09-14 14:00:49 +0000 |
| commit | d3e48e1afc209b7a73e73be76d8033c4ea9035cc (patch) | |
| tree | b425afeb437a9f80e2999c4300fc79b8e4e4bbf5 | |
| parent | 66051faf16c3a19f66d949296387da297de9423b (diff) | |
| download | pyramid-d3e48e1afc209b7a73e73be76d8033c4ea9035cc.tar.gz pyramid-d3e48e1afc209b7a73e73be76d8033c4ea9035cc.tar.bz2 pyramid-d3e48e1afc209b7a73e73be76d8033c4ea9035cc.zip | |
- 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).
| -rw-r--r-- | CHANGES.txt | 10 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_view.py | 2 | ||||
| -rw-r--r-- | 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) |
