doc/book/en/B1020-define-views.en.txt
changeset 316 99943acb44af
parent 309 7067c97cb182
child 318 6cb74102d611
equal deleted inserted replaced
315:210f99896a5b 316:99943acb44af
     9 the development of a web application and how it has been implemented
     9 the development of a web application and how it has been implemented
    10 in `CubicWeb`.
    10 in `CubicWeb`.
    11 
    11 
    12 We'll start with a description of the interface providing you with a basic
    12 We'll start with a description of the interface providing you with a basic
    13 understanding of the classes and methods available, then detail the view
    13 understanding of the classes and methods available, then detail the view
    14 selection principle we makes is makes `CubicWeb` web interface very flexible.
    14 selection principle which makes `CubicWeb` web interface very flexible.
    15 
    15 
    16 Basic class for views
    16 Basic class for views
    17 ---------------------
    17 ---------------------
    18 
    18 
    19 Class `View` (`cubicweb.common.view`)
    19 Class `View` (`cubicweb.common.view`)
    75 * `EmptyRsetView`, view applied to an empty result set
    75 * `EmptyRsetView`, view applied to an empty result set
    76 
    76 
    77 The selection view principle
    77 The selection view principle
    78 ----------------------------
    78 ----------------------------
    79 
    79 
    80 A view includes :
    80 A view is essentially defined by:
    81 
    81 
    82 - an identifier (all objects in `CubicWeb` are entered in a registry
    82 - an identifier (all objects in `CubicWeb` are entered in a registry
    83   and this identifier will be used as a key). This is defined in the class
    83   and this identifier will be used as a key). This is defined in the class
    84   attribute ``id``.
    84   attribute ``id``.
    85   
    85   
    86 - a filter to select the resulsets it can be applied to. This is defined in
    86 - a filter to select the resulsets it can be applied to. This is defined in
    87   the class attribute ``__selectors__``
    87   the class attribute ``__selectors__``, which expects a tuple of selectors
       
    88   as its value.
    88 
    89 
    89 
    90 
    90 For a given identifier, multiple views can be defined. `CubicWeb` uses
    91 For a given identifier, multiple views can be defined. `CubicWeb` uses
    91 a selector which computes scores so that it can identify and select the
    92 a selector which computes scores so that it can identify and select the
    92 best view to apply in context. The selector library is in 
    93 best view to apply in context. The selectors library is in 
    93 ``cubicweb.common.selector`` and a library of the methods used to
    94 ``cubicweb.common.selector`` and a library of the methods used to
    94 compute scores is in ``cubicweb.vregistry.vreq``.
    95 compute scores is in ``cubicweb.vregistry.vreq``.
    95 
    96 
       
    97 .. include:: B1021-views-selectors.en.txt
       
    98 
       
    99 Registerer
       
   100 ``````````
       
   101 A view is also customizable through its attribute ``__registerer__``.
       
   102 This is used at the time the application is launched to manage how
       
   103 objects (views, graphic components, actions, etc.) 
       
   104 are registered in the `cubicWeb` registry.
       
   105 
       
   106 A `registerer` can, for example, identify when we register an 
       
   107 object that is equivalent to an already registered object, which
       
   108 could happen when we define two `primary` views for an entity type.
       
   109 
       
   110 The purpose of a `registerer` is to control objects registry
       
   111 at the application startup whereas `selectors` controls objects
       
   112 when they are selected for display.
       
   113 
    96 
   114 
    97 `CubicWeb` provides a lot of standard views for the default class
   115 `CubicWeb` provides a lot of standard views for the default class
    98 `EntityType`. You can find them in ``cubicweb/web/views/``.
   116 `EntityType`. You can find them in ``cubicweb/web/views/``.
    99 
   117 
   100 .. include:: B1021-views-stdlib.en.txt
   118 .. include:: B1022-views-stdlib.en.txt
   101 
       
   102 
   119 
   103 Example of a view customization
   120 Example of a view customization
   104 -------------------------------
   121 -------------------------------
   105 
   122 
   106 We'll show you now an example of a ``primary`` view and how to customize it.
   123 We'll show you now an example of a ``primary`` view and how to customize it.