doc/book/en/B1021-views-selectors.en.txt
changeset 1808 aa09e20dd8c0
parent 1693 49075f57cf2c
parent 1807 6d541c610165
child 1810 e95e876be17c
equal deleted inserted replaced
1693:49075f57cf2c 1808:aa09e20dd8c0
     1 .. -*- coding: utf-8 -*-
       
     2 
       
     3 Selectors
       
     4 `````````
       
     5 
       
     6 Selectors are scoring functions that are called by the view
       
     7 dispatcher to tell whenever a view can be applied to a given result
       
     8 set of a 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.
       
    11 
       
    12 When no score is higher than the others, an exception is raised
       
    13 ``NoSelectableObject`` to let you know that the engine was not able to
       
    14 identify the view to apply. In such case you would need to review your
       
    15 design and make sure your views are properly defined.
       
    16 
       
    17 `CubicWeb` provides its own set of selectors that you can use and here
       
    18 is a description of some of the most common used:
       
    19 
       
    20 *yes*
       
    21     This selector accepts everything which basically means to any result
       
    22     set.
       
    23 
       
    24 *none_rset*
       
    25     This selector accepts no result set, so it can be applied to any
       
    26     object.
       
    27 
       
    28 *rset*
       
    29     This selector accepts any result set, whatever the number of objects
       
    30     in the result set.
       
    31 
       
    32 *nonempty_rset*
       
    33     This selector accepts any non empty result set.
       
    34 
       
    35 *empty_rset*
       
    36     This selector accepts empty (only) result set.
       
    37 
       
    38 *one_line_rset*
       
    39     This selector accepts result set with a single line of result.
       
    40 
       
    41 *two_lines_rset*
       
    42     This selector accepts result set with *at least* two lines of result.
       
    43 
       
    44 *two_cols_rset*
       
    45     This selector accepts result set with *at least* one line and two columns of result.
       
    46 
       
    47 *anonymous_user*
       
    48     This selector accepts if user is anonymous.
       
    49 
       
    50 *authenticated_user*
       
    51     This selector accepts if user is authenticated.
       
    52 
       
    53 
       
    54 Of course you will write your own set of selectors as you get familiar with the
       
    55 framework.
       
    56