--- a/doc/book/en/development/webstdlib/primary.rst Wed Sep 16 16:14:48 2009 +0200
+++ b/doc/book/en/development/webstdlib/primary.rst Wed Sep 16 16:52:47 2009 +0200
@@ -9,8 +9,9 @@
Rendering methods and attributes for ``PrimaryView``
----------------------------------------------------
-By default, *CubicWeb* provides a primary view for each new entity type
-you create. The first view you might be interested in modifying.
+By default, *CubicWeb* provides a primary view for every available
+entity type. This is the first view you might be interested in
+modifying.
Let's have a quick look at the EntityView ``PrimaryView`` as well as
its rendering method
@@ -24,55 +25,63 @@
show_attr_label = True
show_rel_label = True
skip_none = True
- skip_attrs = ('eid', 'creation_date', 'modification_date')
- skip_rels = ()
+ rsection = uicfg.primaryview_section
+ display_ctrl = uicfg.primaryview_display_ctrl
main_related_section = True
...
def cell_call(self, row, col):
self.row = row
- self.render_entity(self.complete_entity(row, col))
+ self.maxrelated = self.req.property_value('navigation.related-limit')
+ entity = self.complete_entity(row, col)
+ self.render_entity(entity)
def render_entity(self, entity):
- """return html to display the given entity"""
- siderelations = []
self.render_entity_title(entity)
self.render_entity_metadata(entity)
# entity's attributes and relations, excluding meta data
# if the entity isn't meta itself
- self.w(u'<div>')
+ boxes = self._prepare_side_boxes(entity)
+ if boxes or hasattr(self, 'render_side_related'):
+ self.w(u'<table width="100%"><tr><td style="width: 75%">')
+ self.render_entity_summary(entity)
self.w(u'<div class="mainInfo">')
- self.render_entity_attributes(entity, siderelations)
- self.w(u'</div>')
self.content_navigation_components('navcontenttop')
+ self.render_entity_attributes(entity)
if self.main_related_section:
- self.render_entity_relations(entity, siderelations)
+ self.render_entity_relations(entity)
self.w(u'</div>')
# side boxes
- self.w(u'<div class="primaryRight">')
- self.render_side_related(entity, siderelations)
- self.w(u'</div>')
- self.w(u'<div class="clear"></div>')
+ if boxes or hasattr(self, 'render_side_related'):
+ self.w(u'</td><td>')
+ self.w(u'<div class="primaryRight">')
+ if hasattr(self, 'render_side_related'):
+ warn('render_side_related is deprecated')
+ self.render_side_related(entity, [])
+ self.render_side_boxes(boxes)
+ self.w(u'</div>')
+ self.w(u'</td></tr></table>')
self.content_navigation_components('navcontentbottom')
...
-``cell_call`` is executed for each entity of a result set and apply ``render_entity``.
+``cell_call`` is executed for each entity of a result set.
The methods you want to modify while customizing a ``PrimaryView`` are:
*render_entity_title(self, entity)*
Renders the entity title based on the assumption that the method
- ``def content_title(self)`` is implemented for the given entity type.
+ ``def dc_title(self)`` is implemented for the given entity type.
*render_entity_metadata(self, entity)*
- Renders the entity metadata based on the assumption that the method
- ``def summary(self)`` is implemented for the given entity type.
+ Renders the entity metadata by calling the 'metadata' view on the
+ entity. This generic view is in cubicweb.views.baseviews.
-*render_entity_attributes(self, entity, siderelations)*
- Renders all the attribute of an entity with the exception of attribute
- of type `Password` and `Bytes`.
+*render_entity_attributes(self, entity)*
+ Renders all the attribute of an entity with the exception of
+ attribute of type `Password` and `Bytes`. The skip_none class
+ attribute controls the display of None valued attributes.
*content_navigation_components(self, context)*
This method is applicable only for entity type implementing the interface
@@ -81,15 +90,15 @@
entities of this type, either at the top or at the bottom of the page
given the context (navcontent{top|bottom}).
-*render_entity_relations(self, entity, siderelations)*
+*render_entity_relations(self, entity)*
Renders all the relations of the entity in the main section of the page.
-*render_side_related(self, entity, siderelations)*
+*render_side_boxes(self, entity, boxes)*
Renders all the relations of the entity in a side box. This is equivalent
to *render_entity_relations* in addition to render the relations
in a box.
-Also, please note that by setting the following attributes in you class,
+Also, please note that by setting the following attributes in your class,
you can already customize some of the rendering:
*show_attr_label*