Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Consider superclass views after predicate mismatch #1004

Merged
merged 2 commits into from

4 participants

@lrowe

The merged fix for #786 only worked for views registered to an
interface.

lrowe added some commits
@lrowe lrowe Laurence Rowe contributor agreement. 1a48c8b
@lrowe lrowe Consider superclass views after predicate mismatch
The merged fix for #786 only worked for views registered to an
interface.
f3bffdf
@lukecyca

+1

I've tried out this patch with my own pyramid app and it works as expected. This sure makes my life easier. :)

@bertjwregeer

@mmerickel What happened?

@mmerickel mmerickel merged commit f3bffdf into Pylons:master
@mmerickel
Owner

Cool, verified that the test fails on master before the pull, looks good to me.

@lrowe lrowe referenced this pull request from a commit in lrowe/pyramid
@lrowe lrowe 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.
84b9027
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 24, 2013
  1. @lrowe
  2. @lrowe

    Consider superclass views after predicate mismatch

    lrowe authored
    The merged fix for #786 only worked for views registered to an
    interface.
This page is out of date. Refresh to see the latest.
View
2  CONTRIBUTORS.txt
@@ -198,3 +198,5 @@ Contributors
- Georges Dubus, 2013/03/21
- Jason McKellar, 2013/03/28
+
+- Laurence Rowe, 2013/04/24
View
2  pyramid/router.py
@@ -165,7 +165,7 @@ def handle_request(self, request):
except PredicateMismatch:
# look for other views that meet the predicate
# criteria
- for iface in context_iface.flattened():
+ for iface in context_iface.__sro__[1:]:
view_callable = adapters.lookup(
(IViewClassifier, request.request_iface, iface),
IView, name=view_name, default=None)
View
8 pyramid/tests/test_router.py
@@ -1180,11 +1180,9 @@ def test_call_view_predicate_mismatch_doesnt_hide_views(self):
from pyramid.interfaces import IViewClassifier
from pyramid.interfaces import IRequest, IResponse
from pyramid.response import Response
- from zope.interface import Interface, implementer
- class IContext(Interface):
+ class BaseContext:
pass
- @implementer(IContext)
- class DummyContext:
+ class DummyContext(BaseContext):
pass
context = DummyContext()
self._registerTraverserFactory(context)
@@ -1193,7 +1191,7 @@ class DummyContext:
DummyContext)
good_view = DummyView('abc')
self._registerView(self.config.derive_view(good_view),
- '', IViewClassifier, IRequest, IContext)
+ '', IViewClassifier, IRequest, BaseContext)
router = self._makeOne()
def make_response(s):
return Response(s)
Something went wrong with that request. Please try again.