1 The default 'primary' view (:mod:`cubicweb.web.views.primary`) |
1 The default 'primary' view (:mod:`cubicweb.web.views.primary`) |
2 --------------------------------------------------------------- |
2 --------------------------------------------------------------- |
3 |
3 |
4 The primary view of an entity is the view called by default when a single |
4 The primary view of an entity is the view called by default when a single |
5 entity is in the result set and needs to be displayed. |
5 entity is in the result set and needs to be displayed. |
6 |
6 |
7 This view is supposed to render a maximum of informations about the entity. |
7 This view is supposed to render a maximum of informations about the entity. |
8 |
|
9 |
|
10 |
8 |
11 Rendering methods and attributes for ``PrimaryView`` |
9 Rendering methods and attributes for ``PrimaryView`` |
12 ---------------------------------------------------- |
10 ---------------------------------------------------- |
13 |
11 |
14 By default, `CubicWeb` provides a primary view for each new entity type |
12 By default, `CubicWeb` provides a primary view for each new entity type |
16 |
14 |
17 Let's have a quick look at the EntityView ``PrimaryView`` as well as |
15 Let's have a quick look at the EntityView ``PrimaryView`` as well as |
18 its rendering method |
16 its rendering method |
19 |
17 |
20 .. code-block:: python |
18 .. code-block:: python |
21 |
19 |
22 class PrimaryView(EntityView): |
20 class PrimaryView(EntityView): |
23 """the full view of an non final entity""" |
21 """the full view of an non final entity""" |
24 id = 'primary' |
22 id = 'primary' |
25 title = _('primary') |
23 title = _('primary') |
26 show_attr_label = True |
24 show_attr_label = True |
62 |
60 |
63 ``cell_call`` is executed for each entity of a result set and apply ``render_entity``. |
61 ``cell_call`` is executed for each entity of a result set and apply ``render_entity``. |
64 |
62 |
65 The methods you want to modify while customizing a ``PrimaryView`` are: |
63 The methods you want to modify while customizing a ``PrimaryView`` are: |
66 |
64 |
67 *render_entity_title(self, entity)* |
65 *render_entity_title(self, entity)* |
68 Renders the entity title based on the assumption that the method |
66 Renders the entity title based on the assumption that the method |
69 ``def content_title(self)`` is implemented for the given entity type. |
67 ``def content_title(self)`` is implemented for the given entity type. |
70 |
68 |
71 *render_entity_metadata(self, entity)* |
69 *render_entity_metadata(self, entity)* |
72 Renders the entity metadata based on the assumption that the method |
70 Renders the entity metadata based on the assumption that the method |
73 ``def summary(self)`` is implemented for the given entity type. |
71 ``def summary(self)`` is implemented for the given entity type. |
75 *render_entity_attributes(self, entity, siderelations)* |
73 *render_entity_attributes(self, entity, siderelations)* |
76 Renders all the attribute of an entity with the exception of attribute |
74 Renders all the attribute of an entity with the exception of attribute |
77 of type `Password` and `Bytes`. |
75 of type `Password` and `Bytes`. |
78 |
76 |
79 *content_navigation_components(self, context)* |
77 *content_navigation_components(self, context)* |
80 This method is applicable only for entity type implementing the interface |
78 This method is applicable only for entity type implementing the interface |
81 `IPrevNext`. This interface is for entities which can be linked to a previous |
79 `IPrevNext`. This interface is for entities which can be linked to a previous |
82 and/or next entity. This methods will render the navigation links between |
80 and/or next entity. This methods will render the navigation links between |
83 entities of this type, either at the top or at the bottom of the page |
81 entities of this type, either at the top or at the bottom of the page |
84 given the context (navcontent{top|bottom}). |
82 given the context (navcontent{top|bottom}). |
85 |
83 |
86 *render_entity_relations(self, entity, siderelations)* |
84 *render_entity_relations(self, entity, siderelations)* |
87 Renders all the relations of the entity in the main section of the page. |
85 Renders all the relations of the entity in the main section of the page. |
88 |
86 |
89 *render_side_related(self, entity, siderelations)* |
87 *render_side_related(self, entity, siderelations)* |
90 Renders all the relations of the entity in a side box. This is equivalent |
88 Renders all the relations of the entity in a side box. This is equivalent |
91 to *render_entity_relations* in addition to render the relations |
89 to *render_entity_relations* in addition to render the relations |
92 in a box. |
90 in a box. |
93 |
91 |
96 |
94 |
97 *show_attr_label* |
95 *show_attr_label* |
98 Renders the attribute label next to the attribute value if set to True. |
96 Renders the attribute label next to the attribute value if set to True. |
99 Otherwise, does only display the attribute value. |
97 Otherwise, does only display the attribute value. |
100 |
98 |
101 *show_rel_label* |
99 *show_rel_label* |
102 Renders the relation label next to the relation value if set to True. |
100 Renders the relation label next to the relation value if set to True. |
103 Otherwise, does only display the relation value. |
101 Otherwise, does only display the relation value. |
104 |
102 |
105 *skip_none* |
103 *skip_none* |
106 Does not render an attribute value that is None if set to True. |
104 Does not render an attribute value that is None if set to True. |