|
1 .. -*- coding: utf-8 -*- |
|
2 |
|
3 Selectors |
|
4 ````````` |
|
5 |
|
6 A selector is responsible to score how well an object may be used with a |
|
7 given result set during publishing time selection. This enables the selection |
|
8 of the most appropriate views to a given result set. |
|
9 |
|
10 A selector is a method that computes a score. This score is used by |
|
11 `CubicWeb` engine to identify which view is the best to apply in the |
|
12 context. In the case, no score is higher than the others, then an |
|
13 exception is raised ``NoSelectableObject`` to let you know that the |
|
14 engine was not able to identify the view to apply. In such case |
|
15 you would need to review your design and make sure your views are |
|
16 properly defined. |
|
17 |
|
18 `CubicWeb` provides its own set of selectors that you can use and here |
|
19 is a description of some of the most common used: |
|
20 |
|
21 *yes_selector* |
|
22 This selector accepts everything which basically means to any result |
|
23 set. |
|
24 |
|
25 *norset_selector* |
|
26 This selector accepts no result set, so it can be applied to any |
|
27 object. |
|
28 |
|
29 *rset_selector* |
|
30 This selector accepts result set, whatever the number of objects |
|
31 in the result set. |
|
32 |
|
33 *anyrset_selector* |
|
34 This selector accepts any non empty result set. |
|
35 |
|
36 *emptyrset_selector* |
|
37 This selector accepts empty result set. |
|
38 |
|
39 *onelinerset_selector* |
|
40 This selector accepts result set with a single line of result. |
|
41 |
|
42 *twolinerset_selector* |
|
43 This selector accepts result set with *at least* two lines of result. |
|
44 |
|
45 *anonymous_selector* |
|
46 This selector accepts if user is anonymous. |
|
47 |
|
48 *not_anonymous_selector* |
|
49 This selector accepta if user is authenticated. |
|
50 |
|
51 |
|
52 Of course you can write your own set of selectors as you get familiar with the |
|
53 framework. |
|
54 |