predicates.py
changeset 9547 43aace16a953
parent 9344 4da3ef764395
child 9553 be9b12f42d76
--- a/predicates.py	Mon Feb 17 15:01:23 2014 +0100
+++ b/predicates.py	Fri Jan 24 13:08:53 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -707,6 +707,22 @@
 
 # entity predicates #############################################################
 
+class composite_etype(Predicate):
+    """Return 1 for composite entities.
+
+    A composite entity has an etype for which at least one relation
+    definition points in its direction with the
+    composite='subject'/'object' notation.
+    """
+
+    def __call__(self, cls, req, **kwargs):
+        entity = kwargs.pop('entity', None)
+        if entity is None:
+            return 0
+        return entity.e_schema.is_composite
+
+
+
 class non_final_entity(EClassPredicate):
     """Return 1 for entity of a non final entity type(s). Remember, "final"
     entity types are String, Int, etc... This is equivalent to