doc/book/en/B1021-views-selectors.en.txt
changeset 351 ebbcf31e200d
parent 316 99943acb44af
child 356 27eec9130898
equal deleted inserted replaced
349:bc1f1addd34b 351:ebbcf31e200d
     1 .. -*- coding: utf-8 -*-
     1 .. -*- coding: utf-8 -*-
     2 
     2 
     3 Selectors
     3 Selectors
     4 `````````
     4 `````````
     5 
     5 
     6 A selector is responsible to score how well an object may be used with a
     6 Selectors are scoring functions that are called by the view
     7 given result set during publishing time selection. This enables the selection
     7 dispatcher to tell whenever a view can be applied to a given result
     8 of the most appropriate views to a given result set.
     8 set and request. Selector sets are the glue that tie views to the data
       
     9 model. Using them appropriately is an essential part of the
       
    10 construction of well behaved cubes.
     9 
    11 
    10 A selector is a method that computes a score. This score is used by
    12 When no score is higher than the others, an exception is raised
    11 `CubicWeb` engine to identify which view is the best to apply in the
    13 ``NoSelectableObject`` to let you know that the engine was not able to
    12 context. In the case, no score is higher than the others, then an
    14 identify the view to apply. In such case you would need to review your
    13 exception is raised ``NoSelectableObject`` to let you know that the
    15 design and make sure your views are properly defined.
    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 
    16 
    18 `CubicWeb` provides its own set of selectors that you can use and here
    17 `CubicWeb` provides its own set of selectors that you can use and here
    19 is a description of some of the most common used:
    18 is a description of some of the most common used:
    20 
    19 
    21 *yes_selector*
    20 *yes*
    22     This selector accepts everything which basically means to any result
    21     This selector accepts everything which basically means to any result
    23     set.
    22     set.
    24 
    23 
    25 *norset_selector*
    24 *none_rset*
    26     This selector accepts no result set, so it can be applied to any
    25     This selector accepts no result set, so it can be applied to any
    27     object.
    26     object.
    28 
    27 
    29 *rset_selector*
    28 *rset*
    30     This selector accepts result set, whatever the number of objects
    29     This selector accepts any result set, whatever the number of objects
    31     in the result set.
    30     in the result set.
    32 
    31 
    33 *anyrset_selector*
    32 *nonempty_rset*
    34     This selector accepts any non empty result set.
    33     This selector accepts any non empty result set.
    35 
    34 
    36 *emptyrset_selector*
    35 *empty_rset*
    37     This selector accepts empty result set.
    36     This selector accepts empty (only) result set.
    38 
    37 
    39 *onelinerset_selector*
    38 *one_line_rset*
    40     This selector accepts result set with a single line of result.
    39     This selector accepts result set with a single line of result.
    41 
    40 
    42 *twolinerset_selector*
    41 *two_lines_rset*
    43     This selector accepts result set with *at least* two lines of result.
    42     This selector accepts result set with *at least* two lines of result.
    44 
    43 
    45 *anonymous_selector*
    44 *two_cols_rset*
       
    45     This selector accepts result set with *at least* one line and two columns of result.
       
    46 
       
    47 *anonymous_user*
    46     This selector accepts if user is anonymous.
    48     This selector accepts if user is anonymous.
    47 
    49 
    48 *not_anonymous_selector*
    50 *authencated_user*
    49     This selector accepta if user is authenticated.
    51     This selector accepts if user is authenticated.
    50 
    52 
    51 
    53 
    52 Of course you can write your own set of selectors as you get familiar with the
    54 Of course you will write your own set of selectors as you get familiar with the
    53 framework.
    55 framework.
    54 
    56