pyramid_cubicweb/predicates.py
changeset 11600 473754eac7c1
child 11601 23a62d151382
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pyramid_cubicweb/predicates.py	Fri Jul 24 13:39:18 2015 +0200
@@ -0,0 +1,18 @@
+"""Contains predicates used in Pyramid views.
+"""
+
+
+class MatchIsETypePredicate(object):
+    """A predicate that match if a given etype exist in schema.
+    """
+    def __init__(self, matchname, config):
+        self.matchname = matchname
+
+    def text(self):
+        return 'match_is_etype = %s' % self.matchname
+
+    phash = text
+
+    def __call__(self, info, request):
+        return info['match'][self.matchname].lower() in \
+            request.registry['cubicweb.registry'].case_insensitive_etypes