From 84b9027389615084eaf402f8f2aae2ec7199bd67 Mon Sep 17 00:00:00 2001 From: Laurence Rowe Date: Sun, 14 Jul 2013 21:33:24 -0700 Subject: [PATCH] Avoid re-executing the same view when looking up context base views. This is a tweak of #1004. Really we should be using subscribers here instead of adapters, but zope.interface doesn't yet suppport named subscribers. --- pyramid/router.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyramid/router.py b/pyramid/router.py index 3d2a2ff3eb..1a991648bb 100644 --- a/pyramid/router.py +++ b/pyramid/router.py @@ -165,9 +165,13 @@ def handle_request(self, request): # look for other views that meet the predicate # criteria for iface in context_iface.__sro__[1:]: + previous_view_callable = view_callable view_callable = adapters.lookup( (IViewClassifier, request.request_iface, iface), IView, name=view_name, default=None) + # intermediate bases may lookup same view_callable + if view_callable is previous_view_callable: + continue if view_callable is not None: try: response = view_callable(context, request)