equal
deleted
inserted
replaced
17 from logilab.common.compat import all |
17 from logilab.common.compat import all |
18 |
18 |
19 from rql import parse, nodes |
19 from rql import parse, nodes |
20 |
20 |
21 from cubicweb import Unauthorized, typed_eid |
21 from cubicweb import Unauthorized, typed_eid |
22 from cubicweb.vregistry import objectify_selector |
22 from cubicweb.selectors import match_context_prop, abstract_relation_possible |
23 from cubicweb.selectors import match_context_prop, one_has_relation |
|
24 from cubicweb.appobject import AppRsetObject |
23 from cubicweb.appobject import AppRsetObject |
25 from cubicweb.common.registerers import priority_registerer |
24 from cubicweb.common.registerers import priority_registerer |
26 from cubicweb.web.htmlwidgets import HTMLWidget |
25 from cubicweb.web.htmlwidgets import HTMLWidget |
27 |
26 |
28 ## rqlst manipulation functions used by facets ################################ |
27 ## rqlst manipulation functions used by facets ################################ |
332 except Unauthorized: |
331 except Unauthorized: |
333 return [] |
332 return [] |
334 |
333 |
335 |
334 |
336 class RelationFacet(VocabularyFacet): |
335 class RelationFacet(VocabularyFacet): |
337 # XXX find a way to generalize access to cls.rtype |
336 __select__ = abstract_relation_possible() & match_context_prop() |
338 @objectify_selector |
|
339 def my_selector(cls, req, rset, row=None, col=0, **kwargs): |
|
340 selector = (relation_possible(cls.rtype, role(cls)) |
|
341 & match_context_prop()) |
|
342 return selector(cls, req, rset, row, col, **kwargs) |
|
343 |
|
344 __select__ = my_selector() |
|
345 # class attributes to configure the rel ation facet |
337 # class attributes to configure the rel ation facet |
346 rtype = None |
338 rtype = None |
347 role = 'subject' |
339 role = 'subject' |
348 target_attr = 'eid' |
340 target_attr = 'eid' |
349 # set this to a stored procedure name if you want to sort on the result of |
341 # set this to a stored procedure name if you want to sort on the result of |