--- a/doc/book/en/devweb/views/primary.rst Fri Apr 23 17:01:45 2010 +0200
+++ b/doc/book/en/devweb/views/primary.rst Fri Apr 23 20:06:04 2010 +0200
@@ -3,8 +3,6 @@
The Primary View
-----------------
-(:mod:`cubicweb.web.views.primary`)
-
By default, *CubicWeb* provides a view that fits every available
entity type. This is the first view you might be interested in
modifying. It is also one of the richest and most complex.
@@ -15,6 +13,8 @@
This view is supposed to render a maximum of informations about the
entity.
+It lives in the :mod:`cubicweb.web.views.primary` module.
+
.. _primary_view_layout:
Layout
@@ -209,21 +209,23 @@
We continue along the basic tutorial :ref:`tuto_blog`.
-If you want to change the way a ``BlogEntry`` is displayed, just override
-the method ``cell_call()`` of the view ``primary`` in ``BlogDemo/views.py``.
+If you want to change the way a ``BlogEntry`` is displayed, just
+override the method ``cell_call()`` of the view ``primary`` in
+``BlogDemo/views.py``.
.. sourcecode:: python
- from cubicweb.selectors import implements
- from cubicweb.web.views.primary import Primaryview
+ from cubicweb.selectors import implements
+ from cubicweb.web.views.primary import Primaryview
+
+ class BlogEntryPrimaryView(PrimaryView):
+ __select__ = PrimaryView.__select__ & implements('BlogEntry')
- class BlogEntryPrimaryView(PrimaryView):
- __select__ = PrimaryView.__select__ & implements('BlogEntry')
+ def render_entity_attributes(self, entity):
+ self.w(u'<p>published on %s</p>' %
+ entity.publish_date.strftime('%Y-%m-%d'))
+ super(BlogEntryPrimaryView, self).render_entity_attributes(entity)
- def render_entity_attributes(self, entity):
- self.w(u'<p>published on %s</p>' %
- entity.publish_date.strftime('%Y-%m-%d'))
- super(BlogEntryPrimaryView, self).render_entity_attributes(entity)
The above source code defines a new primary view for
``BlogEntry``. The `id` class attribute is not repeated there since it