Skip to content
Browse files

Use predicate.__text__ in predicate mismatch exceptions. See Issue #502

  • Loading branch information...
1 parent 360f251 commit c52e649c6773a99d6077f28ebe0f505d32e72ba6 @adroullier committed
Showing with 7 additions and 5 deletions.
  1. +7 −5 pyramid/config/views.py
View
12 pyramid/config/views.py
@@ -276,11 +276,13 @@ def predicated_view(self, view):
if not predicates:
return view
def predicate_wrapper(context, request):
- if all((predicate(context, request) for predicate in predicates)):
- return view(context, request)
- view_name = getattr(view, '__name__', view)
- raise PredicateMismatch(
- 'predicate mismatch for view %s' % view_name)
+ for predicate in predicates:
+ if not predicate(context, request):
+ view_name = getattr(view, '__name__', view)
+ raise PredicateMismatch(
+ 'predicate mismatch for view %s (%s)' % (
+ view_name, predicate.__text__))
+ return view(context, request)
def checker(context, request):
return all((predicate(context, request) for predicate in
predicates))

0 comments on commit c52e649

Please sign in to comment.
Something went wrong with that request. Please try again.