web/facet.py
branchtls-sprint
changeset 742 99115e029dca
parent 722 50a99184cf47
child 782 01801a10c567
--- a/web/facet.py	Wed Feb 18 00:48:24 2009 +0100
+++ b/web/facet.py	Wed Feb 18 01:21:25 2009 +0100
@@ -19,6 +19,7 @@
 from rql import parse, nodes
 
 from cubicweb import Unauthorized, typed_eid
+from cubicweb.vregistry import objectify_selector
 from cubicweb.selectors import match_context_prop, one_has_relation
 from cubicweb.appobject import AppRsetObject
 from cubicweb.common.registerers import priority_registerer
@@ -333,10 +334,17 @@
 
 
 class RelationFacet(VocabularyFacet):
-    __selectors__ = (one_has_relation, match_context_prop)
-    # class attributes to configure the relation facet
+    # XXX find a way to generalize access to cls.rtype
+    @objectify_selector
+    def my_selector(cls, req, rset, row=None, col=0, **kwargs):
+        selector = (relation_possible(cls.rtype, role(cls))
+                    & match_context_prop())
+        return selector(cls, req, rset, row, col, **kwargs)
+    
+    __select__ = my_selector()
+    # class attributes to configure the rel ation facet
     rtype = None
-    role = 'subject'
+    role = 'subject' 
     target_attr = 'eid'
     # set this to a stored procedure name if you want to sort on the result of
     # this function's result instead of direct value