common/selectors.py
changeset 230 6e71adc5ccdd
parent 215 dfb4ca3ffe78
child 236 8ab9e72dd8f1
--- a/common/selectors.py	Thu Dec 18 10:27:57 2008 -0800
+++ b/common/selectors.py	Fri Dec 19 14:52:42 2008 +0100
@@ -12,7 +12,7 @@
 
 from logilab.common.compat import all
 
-from cubicweb import Unauthorized, NoSelectableObject
+from cubicweb import Unauthorized, NoSelectableObject, role
 from cubicweb.cwvreg import DummyCursorError
 from cubicweb.vregistry import chainall, chainfirst, NoSelectableObject
 from cubicweb.cwconfig import CubicWebConfiguration
@@ -337,6 +337,10 @@
             return 0
     return 1
 
+def has_related_entities(cls, req, rset, row=None, col=None, **kwargs):
+    assert row is not None
+    return bool(rset.get_entity(row, col).related(cls.rtype, role(cls)))
+    
 @lltrace
 def one_has_relation_selector(cls, req, rset, row=None, col=None, **kwargs):
     """check if the user has read access on the relations's type refered by the