doc/book/en/B1021-views-selectors.en.txt
author Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 14 Jan 2009 11:42:52 +0100
changeset 404 867f933eeb89
parent 356 27eec9130898
child 1253 9716a9f77980
permissions -rw-r--r--
[documentation] update cube names and add links to their page on the forge

.. -*- 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 and 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.