# HG changeset patch # User Sylvain Thenault # Date 1229694762 -3600 # Node ID 6e71adc5ccdd3b332911e92890be370ecc7801c2 # Parent 767ff7f5d5a757fdcd7cb283f6a0ff96ab0c34e4 new has_related_entities selector diff -r 767ff7f5d5a7 -r 6e71adc5ccdd common/selectors.py --- 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