doc/book/en/B1021-views-selectors.en.txt
author sylvain.thenault@logilab.fr
Fri, 17 Apr 2009 09:37:29 +0200
branchtls-sprint
changeset 1389 ae58c2e7e1f7
parent 1253 9716a9f77980
permissions -rw-r--r--
clear label handling

.. -*- coding: utf-8 -*-

Selectors
`````````

Selectors are scoring functions that are called by the view
dispatcher to tell whenever a view can be applied to a given result
set of a request. Selector sets are the glue that tie views to the data
model. Using them appropriately is an essential part of the
construction of well behaved cubes.

When no score is higher than the others, an exception is raised
``NoSelectableObject`` to let you know that the engine was not able to
identify the view to apply. In such case you would need to review your
design and make sure your views are properly defined.

`CubicWeb` provides its own set of selectors that you can use and here
is a description of some of the most common used:

*yes*
    This selector accepts everything which basically means to any result
    set.

*none_rset*
    This selector accepts no result set, so it can be applied to any
    object.

*rset*
    This selector accepts any result set, whatever the number of objects
    in the result set.

*nonempty_rset*
    This selector accepts any non empty result set.

*empty_rset*
    This selector accepts empty (only) result set.

*one_line_rset*
    This selector accepts result set with a single line of result.

*two_lines_rset*
    This selector accepts result set with *at least* two lines of result.

*two_cols_rset*
    This selector accepts result set with *at least* one line and two columns of result.

*anonymous_user*
    This selector accepts if user is anonymous.

*authenticated_user*
    This selector accepts if user is authenticated.


Of course you will write your own set of selectors as you get familiar with the
framework.