author | Sylvain Thenault <sylvain.thenault@logilab.fr> |
Fri, 19 Dec 2008 14:52:42 +0100 | |
changeset 230 | 6e71adc5ccdd |
parent 215 | dfb4ca3ffe78 |
child 236 | 8ab9e72dd8f1 |
permissions | -rw-r--r-- |
0 | 1 |
"""This file contains some basic selectors required by application objects. |
2 |
||
3 |
A selector is responsible to score how well an object may be used with a |
|
4 |
given result set (publishing time selection) |
|
5 |
||
6 |
:organization: Logilab |
|
7 |
:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
8 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
9 |
""" |
|
10 |
||
11 |
__docformat__ = "restructuredtext en" |
|
12 |
||
13 |
from logilab.common.compat import all |
|
14 |
||
230
6e71adc5ccdd
new has_related_entities selector
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
215
diff
changeset
|
15 |
from cubicweb import Unauthorized, NoSelectableObject, role |
0 | 16 |
from cubicweb.cwvreg import DummyCursorError |
149 | 17 |
from cubicweb.vregistry import chainall, chainfirst, NoSelectableObject |
0 | 18 |
from cubicweb.cwconfig import CubicWebConfiguration |
19 |
from cubicweb.schema import split_expression |
|
20 |
||
21 |
||
22 |
def lltrace(selector): |
|
23 |
# don't wrap selectors if not in development mode |
|
24 |
if CubicWebConfiguration.mode == 'installed': |
|
25 |
return selector |
|
26 |
def traced(cls, *args, **kwargs): |
|
27 |
ret = selector(cls, *args, **kwargs) |
|
215 | 28 |
cls.lldebug('selector %s returned %s for %s', selector.__name__, ret, cls) |
0 | 29 |
return ret |
30 |
return traced |
|
31 |
||
32 |
# very basic selectors ######################################################## |
|
33 |
||
34 |
def yes_selector(cls, *args, **kwargs): |
|
35 |
"""accept everything""" |
|
36 |
return 1 |
|
37 |
||
38 |
@lltrace |
|
39 |
def norset_selector(cls, req, rset, *args, **kwargs): |
|
40 |
"""accept no result set""" |
|
41 |
if rset is None: |
|
42 |
return 1 |
|
43 |
return 0 |
|
44 |
||
45 |
@lltrace |
|
46 |
def rset_selector(cls, req, rset, *args, **kwargs): |
|
47 |
"""accept result set, whatever the number of result""" |
|
48 |
if rset is not None: |
|
49 |
return 1 |
|
50 |
return 0 |
|
51 |
||
52 |
@lltrace |
|
53 |
def anyrset_selector(cls, req, rset, *args, **kwargs): |
|
54 |
"""accept any non empty result set""" |
|
55 |
if rset and rset.rowcount: # XXX if rset is not None and rset.rowcount > 0: |
|
56 |
return 1 |
|
57 |
return 0 |
|
58 |
||
59 |
@lltrace |
|
60 |
def emptyrset_selector(cls, req, rset, *args, **kwargs): |
|
61 |
"""accept empty result set""" |
|
62 |
if rset is not None and rset.rowcount == 0: |
|
63 |
return 1 |
|
64 |
return 0 |
|
65 |
||
66 |
@lltrace |
|
67 |
def onelinerset_selector(cls, req, rset, row=None, *args, **kwargs): |
|
68 |
"""accept result set with a single line of result""" |
|
69 |
if rset is not None and (row is not None or rset.rowcount == 1): |
|
70 |
return 1 |
|
71 |
return 0 |
|
72 |
||
73 |
@lltrace |
|
74 |
def twolinerset_selector(cls, req, rset, *args, **kwargs): |
|
75 |
"""accept result set with at least two lines of result""" |
|
76 |
if rset is not None and rset.rowcount > 1: |
|
77 |
return 1 |
|
78 |
return 0 |
|
79 |
||
80 |
@lltrace |
|
81 |
def twocolrset_selector(cls, req, rset, *args, **kwargs): |
|
82 |
"""accept result set with at least one line and two columns of result""" |
|
83 |
if rset is not None and rset.rowcount > 0 and len(rset.rows[0]) > 1: |
|
84 |
return 1 |
|
85 |
return 0 |
|
86 |
||
87 |
@lltrace |
|
88 |
def largerset_selector(cls, req, rset, *args, **kwargs): |
|
89 |
"""accept result sets with more rows than the page size |
|
90 |
""" |
|
91 |
if rset is None or len(rset) <= req.property_value('navigation.page-size'): |
|
92 |
return 0 |
|
93 |
return 1 |
|
94 |
||
95 |
@lltrace |
|
96 |
def sortedrset_selector(cls, req, rset, row=None, col=None): |
|
97 |
"""accept sorted result set""" |
|
98 |
rqlst = rset.syntax_tree() |
|
99 |
if len(rqlst.children) > 1 or not rqlst.children[0].orderby: |
|
100 |
return 0 |
|
101 |
return 2 |
|
102 |
||
103 |
@lltrace |
|
104 |
def oneetyperset_selector(cls, req, rset, *args, **kwargs): |
|
105 |
"""accept result set where entities in the first columns are all of the |
|
106 |
same type |
|
107 |
""" |
|
108 |
if len(rset.column_types(0)) != 1: |
|
109 |
return 0 |
|
110 |
return 1 |
|
111 |
||
112 |
@lltrace |
|
113 |
def multitype_selector(cls, req, rset, **kwargs): |
|
114 |
"""accepts resultsets containing several entity types""" |
|
115 |
if rset: |
|
116 |
etypes = rset.column_types(0) |
|
117 |
if len(etypes) > 1: |
|
118 |
return 1 |
|
119 |
return 0 |
|
120 |
||
121 |
@lltrace |
|
122 |
def searchstate_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
123 |
"""extend the anyrset_selector by checking if the current search state |
|
124 |
is in a .search_states attribute of the wrapped class |
|
125 |
||
126 |
search state should be either 'normal' or 'linksearch' (eg searching for an |
|
127 |
object to create a relation with another) |
|
128 |
""" |
|
129 |
try: |
|
130 |
if not req.search_state[0] in cls.search_states: |
|
131 |
return 0 |
|
132 |
except AttributeError: |
|
133 |
return 1 # class don't care about search state, accept it |
|
134 |
return 1 |
|
135 |
||
136 |
@lltrace |
|
137 |
def anonymous_selector(cls, req, *args, **kwargs): |
|
138 |
"""accept if user is anonymous""" |
|
139 |
if req.cnx.anonymous_connection: |
|
140 |
return 1 |
|
141 |
return 0 |
|
142 |
||
143 |
@lltrace |
|
144 |
def not_anonymous_selector(cls, req, *args, **kwargs): |
|
145 |
"""accept if user is anonymous""" |
|
146 |
return not anonymous_selector(cls, req, *args, **kwargs) |
|
147 |
||
148 |
||
149 |
# not so basic selectors ###################################################### |
|
150 |
||
151 |
@lltrace |
|
152 |
def req_form_params_selector(cls, req, *args, **kwargs): |
|
153 |
"""check if parameters specified by the form_params attribute on |
|
154 |
the wrapped class are specified in request form parameters |
|
155 |
""" |
|
156 |
score = 0 |
|
157 |
for param in cls.form_params: |
|
158 |
val = req.form.get(param) |
|
159 |
if not val: |
|
160 |
return 0 |
|
161 |
score += 1 |
|
162 |
return score + 1 |
|
163 |
||
164 |
@lltrace |
|
165 |
def kwargs_selector(cls, req, *args, **kwargs): |
|
166 |
"""check if arguments specified by the expected_kwargs attribute on |
|
167 |
the wrapped class are specified in given named parameters |
|
168 |
""" |
|
169 |
values = [] |
|
170 |
for arg in cls.expected_kwargs: |
|
171 |
if not arg in kwargs: |
|
172 |
return 0 |
|
173 |
return 1 |
|
174 |
||
175 |
@lltrace |
|
176 |
def etype_form_selector(cls, req, *args, **kwargs): |
|
177 |
"""check etype presence in request form *and* accepts conformance""" |
|
178 |
if 'etype' not in req.form and 'etype' not in kwargs: |
|
179 |
return 0 |
|
180 |
try: |
|
181 |
etype = req.form['etype'] |
|
182 |
except KeyError: |
|
183 |
etype = kwargs['etype'] |
|
184 |
# value is a list or a tuple if web request form received several |
|
185 |
# values for etype parameter |
|
186 |
assert isinstance(etype, basestring), "got multiple etype parameters in req.form" |
|
187 |
if 'Any' in cls.accepts: |
|
188 |
return 1 |
|
189 |
# no Any found, we *need* exact match |
|
190 |
if etype not in cls.accepts: |
|
191 |
return 0 |
|
192 |
# exact match must return a greater value than 'Any'-match |
|
193 |
return 2 |
|
194 |
||
195 |
@lltrace |
|
196 |
def _nfentity_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
197 |
"""accept non final entities |
|
198 |
if row is not specified, use the first one |
|
199 |
if col is not specified, use the first one |
|
200 |
""" |
|
201 |
etype = rset.description[row or 0][col or 0] |
|
202 |
if etype is None: # outer join |
|
203 |
return 0 |
|
204 |
if cls.schema.eschema(etype).is_final(): |
|
205 |
return 0 |
|
206 |
return 1 |
|
207 |
||
208 |
@lltrace |
|
209 |
def _rqlcondition_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
210 |
"""accept single entity result set if the entity match an rql condition |
|
211 |
""" |
|
212 |
if cls.condition: |
|
213 |
eid = rset[row or 0][col or 0] |
|
214 |
if 'U' in frozenset(split_expression(cls.condition)): |
|
215 |
rql = 'Any X WHERE X eid %%(x)s, U eid %%(u)s, %s' % cls.condition |
|
216 |
else: |
|
217 |
rql = 'Any X WHERE X eid %%(x)s, %s' % cls.condition |
|
218 |
try: |
|
219 |
return len(req.execute(rql, {'x': eid, 'u': req.user.eid}, 'x')) |
|
220 |
except Unauthorized: |
|
221 |
return 0 |
|
222 |
||
223 |
return 1 |
|
224 |
||
225 |
@lltrace |
|
226 |
def _interface_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
227 |
"""accept uniform result sets, and apply the following rules: |
|
228 |
||
229 |
* wrapped class must have a accepts_interfaces attribute listing the |
|
230 |
accepted ORed interfaces |
|
231 |
* if row is None, return the sum of values returned by the method |
|
232 |
for each entity's class in the result set. If any score is 0, |
|
233 |
return 0. |
|
234 |
* if row is specified, return the value returned by the method with |
|
235 |
the entity's class of this row |
|
236 |
""" |
|
184
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
237 |
# XXX this selector can be refactored : extract the code testing |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
238 |
# for entity schema / interface compliance |
0 | 239 |
score = 0 |
240 |
# check 'accepts' to give priority to more specific classes |
|
241 |
if row is None: |
|
242 |
for etype in rset.column_types(col or 0): |
|
243 |
eclass = cls.vreg.etype_class(etype) |
|
244 |
escore = 0 |
|
245 |
for iface in cls.accepts_interfaces: |
|
246 |
escore += iface.is_implemented_by(eclass) |
|
247 |
if not escore: |
|
248 |
return 0 |
|
249 |
score += escore |
|
184
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
250 |
accepts = set(getattr(cls, 'accepts', ())) |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
251 |
# if accepts is defined on the vobject, eclass must match |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
252 |
if accepts: |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
253 |
eschema = eclass.e_schema |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
254 |
etypes = set([eschema] + eschema.ancestors()) |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
255 |
if accepts & etypes: |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
256 |
score += 2 |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
257 |
elif 'Any' not in accepts: |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
258 |
return 0 |
0 | 259 |
return score + 1 |
260 |
etype = rset.description[row][col or 0] |
|
261 |
if etype is None: # outer join |
|
262 |
return 0 |
|
263 |
eclass = cls.vreg.etype_class(etype) |
|
264 |
for iface in cls.accepts_interfaces: |
|
265 |
score += iface.is_implemented_by(eclass) |
|
266 |
if score: |
|
184
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
267 |
accepts = set(getattr(cls, 'accepts', ())) |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
268 |
# if accepts is defined on the vobject, eclass must match |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
269 |
if accepts: |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
270 |
eschema = eclass.e_schema |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
271 |
etypes = set([eschema] + eschema.ancestors()) |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
272 |
if accepts & etypes: |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
273 |
score += 1 |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
274 |
elif 'Any' not in accepts: |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
275 |
return 0 |
92aebc6b533c
fix interface_selector bug
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
162
diff
changeset
|
276 |
score += 1 |
0 | 277 |
return score |
278 |
||
279 |
@lltrace |
|
280 |
def score_entity_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
281 |
if row is None: |
|
282 |
rows = xrange(rset.rowcount) |
|
283 |
else: |
|
284 |
rows = (row,) |
|
285 |
for row in rows: |
|
286 |
try: |
|
287 |
score = cls.score_entity(rset.get_entity(row, col or 0)) |
|
288 |
except DummyCursorError: |
|
289 |
# get a dummy cursor error, that means we are currently |
|
290 |
# using a dummy rset to list possible views for an entity |
|
291 |
# type, not for an actual result set. In that case, we |
|
292 |
# don't care of the value, consider the object as selectable |
|
293 |
return 1 |
|
294 |
if not score: |
|
295 |
return 0 |
|
296 |
return 1 |
|
297 |
||
298 |
@lltrace |
|
299 |
def accept_rset_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
300 |
"""simply delegate to cls.accept_rset method""" |
|
301 |
return cls.accept_rset(req, rset, row=row, col=col) |
|
302 |
||
303 |
@lltrace |
|
304 |
def but_etype_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
305 |
"""restrict the searchstate_accept_one_selector to exclude entity's type |
|
306 |
refered by the .etype attribute |
|
307 |
""" |
|
308 |
if rset.description[row or 0][col or 0] == cls.etype: |
|
309 |
return 0 |
|
310 |
return 1 |
|
311 |
||
312 |
@lltrace |
|
313 |
def etype_rtype_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
314 |
"""only check if the user has read access on the entity's type refered |
|
315 |
by the .etype attribute and on the relations's type refered by the |
|
316 |
.rtype attribute if set. |
|
317 |
""" |
|
318 |
schema = cls.schema |
|
319 |
perm = getattr(cls, 'require_permission', 'read') |
|
320 |
if hasattr(cls, 'etype'): |
|
321 |
eschema = schema.eschema(cls.etype) |
|
322 |
if not (eschema.has_perm(req, perm) or eschema.has_local_role(perm)): |
|
323 |
return 0 |
|
324 |
if hasattr(cls, 'rtype'): |
|
325 |
if not schema.rschema(cls.rtype).has_perm(req, perm): |
|
326 |
return 0 |
|
327 |
return 1 |
|
328 |
||
329 |
@lltrace |
|
330 |
def accept_rtype_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
331 |
if hasattr(cls, 'rtype'): |
|
332 |
if row is None: |
|
333 |
for etype in rset.column_types(col or 0): |
|
334 |
if not cls.relation_possible(etype): |
|
335 |
return 0 |
|
336 |
elif not cls.relation_possible(rset.description[row][col or 0]): |
|
337 |
return 0 |
|
338 |
return 1 |
|
339 |
||
230
6e71adc5ccdd
new has_related_entities selector
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
215
diff
changeset
|
340 |
def has_related_entities(cls, req, rset, row=None, col=None, **kwargs): |
6e71adc5ccdd
new has_related_entities selector
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
215
diff
changeset
|
341 |
assert row is not None |
6e71adc5ccdd
new has_related_entities selector
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
215
diff
changeset
|
342 |
return bool(rset.get_entity(row, col).related(cls.rtype, role(cls))) |
6e71adc5ccdd
new has_related_entities selector
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
215
diff
changeset
|
343 |
|
0 | 344 |
@lltrace |
345 |
def one_has_relation_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
346 |
"""check if the user has read access on the relations's type refered by the |
|
347 |
.rtype attribute of the class, and if at least one entity type in the |
|
348 |
result set has this relation. |
|
349 |
""" |
|
350 |
schema = cls.schema |
|
351 |
perm = getattr(cls, 'require_permission', 'read') |
|
352 |
if not schema.rschema(cls.rtype).has_perm(req, perm): |
|
353 |
return 0 |
|
354 |
if row is None: |
|
355 |
for etype in rset.column_types(col or 0): |
|
356 |
if cls.relation_possible(etype): |
|
357 |
return 1 |
|
358 |
elif cls.relation_possible(rset.description[row][col or 0]): |
|
359 |
return 1 |
|
360 |
return 0 |
|
361 |
||
362 |
@lltrace |
|
363 |
def in_group_selector(cls, req, rset=None, row=None, col=None, **kwargs): |
|
364 |
"""select according to user's groups""" |
|
365 |
if not cls.require_groups: |
|
366 |
return 1 |
|
367 |
user = req.user |
|
368 |
if user is None: |
|
369 |
return int('guests' in cls.require_groups) |
|
370 |
score = 0 |
|
371 |
if 'owners' in cls.require_groups and rset: |
|
372 |
if row is not None: |
|
373 |
eid = rset[row][col or 0] |
|
374 |
if user.owns(eid): |
|
375 |
score = 1 |
|
376 |
else: |
|
377 |
score = all(user.owns(r[col or 0]) for r in rset) |
|
378 |
score += user.matching_groups(cls.require_groups) |
|
379 |
if score: |
|
380 |
# add 1 so that an object with one matching group take priority |
|
381 |
# on an object without require_groups |
|
382 |
return score + 1 |
|
383 |
return 0 |
|
384 |
||
385 |
@lltrace |
|
386 |
def add_etype_selector(cls, req, rset, row=None, col=None, **kwargs): |
|
387 |
"""only check if the user has add access on the entity's type refered |
|
388 |
by the .etype attribute. |
|
389 |
""" |
|
390 |
if not cls.schema.eschema(cls.etype).has_perm(req, 'add'): |
|
391 |
return 0 |
|
392 |
return 1 |
|
393 |
||
394 |
@lltrace |
|
395 |
def contextprop_selector(cls, req, rset, row=None, col=None, context=None, |
|
396 |
**kwargs): |
|
397 |
propval = req.property_value('%s.%s.context' % (cls.__registry__, cls.id)) |
|
398 |
if not propval: |
|
399 |
propval = cls.context |
|
400 |
if context is not None and propval is not None and context != propval: |
|
401 |
return 0 |
|
402 |
return 1 |
|
403 |
||
404 |
@lltrace |
|
405 |
def primaryview_selector(cls, req, rset, row=None, col=None, view=None, |
|
406 |
**kwargs): |
|
407 |
if view is not None and not view.is_primary(): |
|
408 |
return 0 |
|
409 |
return 1 |
|
410 |
||
142
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
411 |
def appobject_selectable(registry, oid): |
161
328bc32b5701
repairing error from preceding commit
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
157
diff
changeset
|
412 |
"""return a selector that will have a positive score if an object for the |
328bc32b5701
repairing error from preceding commit
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
157
diff
changeset
|
413 |
given registry and object id is selectable for the input context |
328bc32b5701
repairing error from preceding commit
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
157
diff
changeset
|
414 |
""" |
142
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
415 |
@lltrace |
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
416 |
def selector(cls, req, rset, *args, **kwargs): |
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
417 |
try: |
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
418 |
cls.vreg.select_object(registry, oid, req, rset, *args, **kwargs) |
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
419 |
return 1 |
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
420 |
except NoSelectableObject: |
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
421 |
return 0 |
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
422 |
return selector |
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
423 |
|
0 | 424 |
|
425 |
# compound selectors ########################################################## |
|
426 |
||
427 |
nfentity_selector = chainall(anyrset_selector, _nfentity_selector) |
|
428 |
interface_selector = chainall(nfentity_selector, _interface_selector) |
|
429 |
||
430 |
accept_selector = chainall(nfentity_selector, accept_rset_selector) |
|
431 |
accept_one_selector = chainall(onelinerset_selector, accept_selector) |
|
432 |
||
433 |
rqlcondition_selector = chainall(nfentity_selector, |
|
434 |
onelinerset_selector, |
|
435 |
_rqlcondition_selector) |
|
436 |
||
437 |
searchstate_accept_selector = chainall(anyrset_selector, searchstate_selector, |
|
438 |
accept_selector) |
|
439 |
searchstate_accept_one_selector = chainall(anyrset_selector, searchstate_selector, |
|
440 |
accept_selector, rqlcondition_selector) |
|
441 |
searchstate_accept_one_but_etype_selector = chainall(searchstate_accept_one_selector, |
|
442 |
but_etype_selector) |
|
443 |
||
444 |
__all__ = [name for name in globals().keys() if name.endswith('selector')] |
|
445 |
__all__ += ['chainall', 'chainfirst'] |