equal
deleted
inserted
replaced
1 """contains utility functions and some visual component to restrict results of |
1 """contains utility functions and some visual component to restrict results of |
2 a search |
2 a search |
3 |
3 |
4 :organization: Logilab |
4 :organization: Logilab |
5 :copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 """ |
7 """ |
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 |
9 |
10 from itertools import chain |
10 from itertools import chain |
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.common.selectors import contextprop_selector, one_has_relation_selector |
22 from cubicweb.common.selectors import match_context_prop, one_has_relation |
23 from cubicweb.common.registerers import priority_registerer |
23 from cubicweb.common.registerers import priority_registerer |
24 from cubicweb.common.appobject import AppRsetObject |
24 from cubicweb.common.appobject import AppRsetObject |
25 from cubicweb.common.utils import AcceptMixIn |
25 from cubicweb.common.utils import AcceptMixIn |
26 from cubicweb.web.htmlwidgets import HTMLWidget |
26 from cubicweb.web.htmlwidgets import HTMLWidget |
27 |
27 |
224 if vref.name == trvarname: |
224 if vref.name == trvarname: |
225 rqlst.remove_group_var(vref) |
225 rqlst.remove_group_var(vref) |
226 # we can also remove all variables which are linked to this variable |
226 # we can also remove all variables which are linked to this variable |
227 # and have no path to the main variable |
227 # and have no path to the main variable |
228 for ovarname in linkedvars: |
228 for ovarname in linkedvars: |
|
229 if ovarname == mainvar.name: |
|
230 continue |
229 if not has_path(vargraph, ovarname, mainvar.name): |
231 if not has_path(vargraph, ovarname, mainvar.name): |
230 toremove.add(rqlst.defined_vars[ovarname]) |
232 toremove.add(rqlst.defined_vars[ovarname]) |
231 |
233 |
232 |
234 |
233 |
235 |
330 except Unauthorized: |
332 except Unauthorized: |
331 return [] |
333 return [] |
332 |
334 |
333 |
335 |
334 class RelationFacet(VocabularyFacet): |
336 class RelationFacet(VocabularyFacet): |
335 __selectors__ = (one_has_relation_selector, contextprop_selector) |
337 __selectors__ = (one_has_relation, match_context_prop) |
336 # class attributes to configure the relation facet |
338 # class attributes to configure the relation facet |
337 rtype = None |
339 rtype = None |
338 role = 'subject' |
340 role = 'subject' |
339 target_attr = 'eid' |
341 target_attr = 'eid' |
340 # set this to a stored procedure name if you want to sort on the result of |
342 # set this to a stored procedure name if you want to sort on the result of |