doc/book/en/development/vreg/selectors.rst
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 06 Apr 2010 10:10:47 +0200
branchstable
changeset 5146 fe56baf63ecb
parent 5143 43afbdd5c8b4
permissions -rw-r--r--
add note about running repository / client code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     1
Base selectors
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     2
--------------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     3
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
     4
Selectors are scoring functions that are called by the registry to tell whenever
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
     5
an appobject can be selected in a given context. Selector sets are for instance
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
     6
the glue that tie views to the data model. Using them appropriately is an
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
essential part of the construction of well behaved cubes.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     8
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
     9
Of course you may have to write your own set of selectors as your needs grows and
4936
a4b772a0d801 Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents: 4463
diff changeset
    10
you get familiar with the framework (see :ref:`CustomSelectors`).
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    11
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    12
Here is a description of generic selectors provided by CubicWeb that should suit
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    13
most of your needs.
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    14
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    15
Bare selectors
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    16
~~~~~~~~~~~~~~
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    17
Those selectors are somewhat dumb, which doesn't mean they're not (very) useful.
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    18
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    19
.. autoclass:: cubicweb.appobject.yes
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    20
.. autoclass:: cubicweb.selectors.match_kwargs
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    21
.. autoclass:: cubicweb.selectors.appobject_selectable
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    22
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    23
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    24
Result set selectors
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    25
~~~~~~~~~~~~~~~~~~~~~
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    26
Those selectors are looking for a result set in the context ('rset' argument or
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    27
the input context) and match or not according to its shape. Some of these
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    28
selectors have different behaviour if a particular cell of the result set is
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    29
specified using 'row' and 'col' arguments of the input context or not.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    30
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    31
.. autoclass:: cubicweb.selectors.none_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    32
.. autoclass:: cubicweb.selectors.any_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    33
.. autoclass:: cubicweb.selectors.nonempty_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    34
.. autoclass:: cubicweb.selectors.empty_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    35
.. autoclass:: cubicweb.selectors.one_line_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    36
.. autoclass:: cubicweb.selectors.multi_lines_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    37
.. autoclass:: cubicweb.selectors.multi_columns_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    38
.. autoclass:: cubicweb.selectors.paginated_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    39
.. autoclass:: cubicweb.selectors.sorted_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    40
.. autoclass:: cubicweb.selectors.one_etype_rset
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    41
.. autoclass:: cubicweb.selectors.multi_etypes_rset
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    42
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    43
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    44
Entity selectors
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    45
~~~~~~~~~~~~~~~~
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    46
Those selectors are looking for either an `entity` argument in the input context,
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    47
or entity found in the result set ('rset' argument or the input context) and
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    48
match or not according to entity's (instance or class) properties.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    49
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    50
.. autoclass:: cubicweb.selectors.non_final_entity
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    51
.. autoclass:: cubicweb.selectors.implements
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    52
.. autoclass:: cubicweb.selectors.score_entity
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    53
.. autoclass:: cubicweb.selectors.rql_condition
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    54
.. autoclass:: cubicweb.selectors.relation_possible
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    55
.. autoclass:: cubicweb.selectors.partial_relation_possible
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    56
.. autoclass:: cubicweb.selectors.has_related_entities
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    57
.. autoclass:: cubicweb.selectors.partial_has_related_entities
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    58
.. autoclass:: cubicweb.selectors.has_permission
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    59
.. autoclass:: cubicweb.selectors.has_add_permission
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    60
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    61
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    62
Logged user selectors
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    63
~~~~~~~~~~~~~~~~~~~~~
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    64
Those selectors are looking for properties of the user issuing the request.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    65
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    66
.. autoclass:: cubicweb.selectors.anonymous_user
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    67
.. autoclass:: cubicweb.selectors.authenticated_user
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    68
.. autoclass:: cubicweb.selectors.match_user_groups
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    69
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    70
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    71
Web request selectors
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    72
~~~~~~~~~~~~~~~~~~~~~
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    73
Those selectors are looking for properties of *web* request, they can not be
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    74
used on the data repository side.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    75
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    76
.. autoclass:: cubicweb.selectors.match_form_params
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    77
.. autoclass:: cubicweb.selectors.match_search_state
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    78
.. autoclass:: cubicweb.selectors.match_context_prop
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    79
.. autoclass:: cubicweb.selectors.match_view
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    80
.. autoclass:: cubicweb.selectors.primary_view
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    81
.. autoclass:: cubicweb.selectors.specified_etype_implements
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    82
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    83
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    84
Other selectors
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    85
~~~~~~~~~~~~~~~
4463
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    86
.. autoclass:: cubicweb.selectors.match_transition
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    87
b071d5c6b48f more selectors doc in the book, mostly extracted from code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4437
diff changeset
    88
You'll also find some other (very) specific selectors hidden in other modules
4936
a4b772a0d801 Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents: 4463
diff changeset
    89
than :mod:`cubicweb.selectors`.