From 34d4cd0ea38fdbe0ab0e0832fc2114953ef4e94a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 4 Nov 2012 01:02:19 -0500 Subject: - In uncommon cases, the ``pyramid_excview_tween_factory`` might have inadvertently raised a ``KeyError`` looking for ``request_iface`` as an attribute of the request. It no longer fails in this case. See https://github.com/Pylons/pyramid/issues/700 Fixes #700 --- CHANGES.txt | 5 +++++ pyramid/tweens.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 298bddf7a..8d5a00e77 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -38,6 +38,11 @@ Bug Fixes be unmolested on the way out. See https://github.com/Pylons/pyramid/issues/709 +- In uncommon cases, the ``pyramid_excview_tween_factory`` might have + inadvertently raised a ``KeyError`` looking for ``request_iface`` as an + attribute of the request. It no longer fails in this case. See + https://github.com/Pylons/pyramid/issues/700 + Internals --------- diff --git a/pyramid/tweens.py b/pyramid/tweens.py index 73a95e1b8..cf2238deb 100644 --- a/pyramid/tweens.py +++ b/pyramid/tweens.py @@ -2,6 +2,7 @@ import sys from pyramid.interfaces import ( IExceptionViewClassifier, + IRequest, IView, ) @@ -28,7 +29,9 @@ def excview_tween_factory(handler, registry): # sane (e.g. caching headers) if 'response' in attrs: del attrs['response'] - request_iface = attrs['request_iface'] + # we use .get instead of .__getitem__ below due to + # https://github.com/Pylons/pyramid/issues/700 + request_iface = attrs.get('request_iface', IRequest) provides = providedBy(exc) for_ = (IExceptionViewClassifier, request_iface.combined, provides) view_callable = adapters.lookup(for_, IView, default=None) -- cgit v1.2.3