doc/book/en/devweb/views/basetemplates.rst
author Stephanie Marcu <stephanie.marcu@logilab.fr>
Wed, 22 Sep 2010 13:33:17 +0200
branchstable
changeset 6302 ca5d09ff0379
parent 5394 105011657405
child 6880 4be32427b2b9
permissions -rw-r--r--
[book - #1251259] reorganize plan for basetemplate, talk about class attributes
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
.. -*- coding: utf-8 -*-
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     2
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
     3
.. |cubicweb| replace:: *CubicWeb*
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
     4
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
.. _templates:
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     6
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
Templates
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     8
=========
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     9
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    10
Templates are the entry point for the |cubicweb| view system. As seen
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    11
in :ref:`views_base_class`, there are two kinds of views: the
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    12
templatable and non-templatable.
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    13
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    14
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    15
Non-templatable views
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    16
---------------------
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    17
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    18
Non-templatable views are standalone. They are responsible for all the details
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    19
such as setting a proper content type (or mime type), the proper document
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    20
headers, namespaces, etc. Examples are pure xml views such as RSS or Semantic Web
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    21
views (`SIOC`_, `DOAP`_, `FOAF`_, `Linked Data`_, etc.), and views which generate
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    22
binary files (pdf, excel files, etc.)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    23
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    24
.. _`SIOC`: http://sioc-project.org/
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    25
.. _`DOAP`: http://trac.usefulinc.com/doap
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    26
.. _`FOAF`: http://www.foaf-project.org/
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    27
.. _`Linked Data`: http://linkeddata.org/
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    28
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    29
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    30
To notice that a view is not templatable, you just have to set the
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    31
view's class attribute `templatable` to `False`. In this case, it
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    32
should set the `content_type` class attribute to the correct MIME
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    33
type. By default, it is text/xhtml. Additionally, if your view
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    34
generate a binary file, you have to set the view's class attribute
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    35
`binary` to `True` too.
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    36
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    37
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    38
Templatable views
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    39
-----------------
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    40
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    41
Templatable views are not concerned with such pesky details. They
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    42
leave it to the template. Conversely, the template's main job is to:
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    43
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    44
* set up the proper document header and content type
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    45
* define the general layout of a document
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    46
* invoke adequate views in the various sections of the document
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    47
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    48
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    49
Look at :mod:`cubicweb.web.views.basetemplates` and you will find the base
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    50
templates used to generate (X)HTML for your application. The most important
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    51
template there is :class:`~cubicweb.web.views.basetemplates.TheMainTemplate`.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    52
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    53
.. _the_main_template_layout:
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    54
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    55
TheMainTemplate
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
    56
~~~~~~~~~~~~~~~
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    57
5308
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5290
diff changeset
    58
.. _the_main_template_sections:
c691a424d9e0 [doc/book] complete the breadcrumbs section
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5290
diff changeset
    59
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    60
Layout and sections
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    61
```````````````````
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    62
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    63
A page is composed as indicated on the schema below :
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    64
5394
105011657405 [doc/book] move devweb up from development, turn development into devrepo (much better structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5308
diff changeset
    65
.. image:: ../../images/main_template.png
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    66
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    67
The sections dispatches specific views:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    68
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    69
* `header`: the rendering of the header is delegated to the
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    70
  `htmlheader` view, whose default implementation can be found in
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    71
  ``basetemplates.py`` and which does the following things:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    72
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    73
    * inject the favicon if there is one
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    74
    * inject the global style sheets and javascript resources
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    75
    * call and display a link to an rss component if there is one available
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    76
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    77
  it also sets up the page title, and fills the actual
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    78
  `header` section with top-level components, using the `header` view, which:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    79
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    80
    * tries to display a logo, the name of the application and the `breadcrumbs`
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    81
    * provides a login status area
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    82
    * provides a login box (hiden by default)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    83
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    84
* `left column`: this is filled with all selectable boxes matching the
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    85
  `left` context (there is also a right column but nowadays it is
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    86
  seldom used due to bad usability)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    87
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    88
* `contentcol`: this is the central column; it is filled with:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    89
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    90
    * the `rqlinput` view (hidden by default)
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    91
    * the `applmessages` component
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    92
    * the `contentheader` view which in turns dispatches all available
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    93
      content navigation components having the `navtop` context (this
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    94
      is used to navigate through entities implementing the IPrevNext
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    95
      interface)
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    96
    * the view that was given as input to the template's `call`
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    97
      method, also dealing with pagination concerns
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
    98
    * the `contentfooter`
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    99
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
   100
* `footer`: adds all footer actions
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   101
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
   102
.. note::
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   103
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
   104
  How and why a view object is given to the main template is explained
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
   105
  in the :ref:`publisher` chapter.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   106
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   107
Configure the main template
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   108
```````````````````````````
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   109
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   110
You can overload some methods of the
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   111
:class:`~cubicweb.web.views.basetemplates.TheMainTemplate`, in order to fulfil
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   112
your needs. There are also some attributes and methods which can be defined on a
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   113
view to modify the base template behaviour:
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   114
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   115
* `paginable`: if the result set is bigger than a configurable size, your result
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   116
  page will be paginated by default. You can set this attribute to `False` to
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   117
  avoid this.
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   118
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   119
* `binary`: boolean flag telling if the view generates some text or a binary
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   120
  stream.  Default to False. When view generates text argument given to `self.w`
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   121
  **must be an unicode string**, encoded string otherwise.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   122
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   123
* `content_type`, view's content type, default to 'text/xhtml'
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   124
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   125
* `templatable`, boolean flag telling if the view's content should be returned
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   126
  directly (when `False`) or included in the main template layout (including
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   127
  header, boxes and so on).
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   128
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   129
* `page_title()`, method that should return a title that will be set as page
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   130
  title in the html headers.
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   131
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   132
* `html_headers()`, method that should return a list of HTML headers to be
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   133
  included the html headers.
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   134
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   135
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   136
You can also modify certain aspects of the main template of a page
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   137
when building an url or setting these parameters in the req.form:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   138
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   139
* `__notemplate`, if present (whatever the value assigned), only the content view
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   140
  is returned
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   141
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   142
* `__force_display`, if present and its value is not null, no pagination whatever
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   143
  the number of entities to display (e.g. similar effect as view's `paginable`
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   144
  attribute described above.
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   145
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   146
* `__method`, if the result set to render contains only one entity and this
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   147
  parameter is set, it refers to a method to call on the entity by passing it the
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   148
  dictionary of the forms parameters, before going the classic way (through step
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   149
  1 and 2 described juste above)
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   150
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   151
* `vtitle`, a title to be set as <h1> of the content
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   152
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
   153
Other templates
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   154
~~~~~~~~~~~~~~~
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
   155
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   156
There are also the following other standard templates:
5284
ad922b7449aa [doc/book] rework the templates chapter (wipe out horrible example, talk more about structure)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5269
diff changeset
   157
6302
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   158
* :class:`cubicweb.web.views.basetemplates.LogInTemplate`
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   159
* :class:`cubicweb.web.views.basetemplates.LogOutTemplate`
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   160
* :class:`cubicweb.web.views.basetemplates.ErrorTemplate` specializes
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   161
  :class:`~cubicweb.web.views.basetemplates.TheMainTemplate` to do
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   162
  proper end-user output if an error occurs during the computation of
ca5d09ff0379 [book - #1251259] reorganize plan for basetemplate, talk about class attributes
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5394
diff changeset
   163
  TheMainTemplate (it is a fallback view).