113 def summary(self, entity): |
113 def summary(self, entity): |
114 """default implementation return an empty string""" |
114 """default implementation return an empty string""" |
115 return u'' |
115 return u'' |
116 |
116 |
117 def render_entity_attributes(self, entity, siderelations=None): |
117 def render_entity_attributes(self, entity, siderelations=None): |
118 entity_attributes = self._section_def(entity, 'attributes') |
118 display_attributes = [] |
119 if not entity_attributes: |
119 for rschema, _, role, dispctrl in self._section_def(entity, 'attributes'): |
120 return |
|
121 self.w(u'<table>') |
|
122 for rschema, tschemas, role, dispctrl in entity_attributes: |
|
123 vid = dispctrl.get('vid', 'reledit') |
120 vid = dispctrl.get('vid', 'reledit') |
124 if rschema.final or vid == 'reledit': |
121 if rschema.final or vid == 'reledit': |
125 value = entity.view(vid, rtype=rschema.type, role=role) |
122 value = entity.view(vid, rtype=rschema.type, role=role) |
126 else: |
123 else: |
127 rset = self._relation_rset(entity, rschema, role, dispctrl) |
124 rset = self._relation_rset(entity, rschema, role, dispctrl) |
128 if rset: |
125 if rset: |
129 value = self._cw.view(vid, rset) |
126 value = self._cw.view(vid, rset) |
130 else: |
127 else: |
131 value = None |
128 value = None |
132 if self.skip_none and (value is None or value == ''): |
129 if not self.skip_none or (value is not None and value != ''): |
133 continue |
130 display_attributes.append( (rschema, role, dispctrl, value) ) |
134 try: |
131 if display_attributes: |
135 self._render_attribute(dispctrl, rschema, value, |
132 self.w(u'<table>') |
136 role=role, table=True) |
133 for rschema, role, dispctrl, value in entity_attributes: |
137 except TypeError: |
134 try: |
138 warn('[3.6] _render_attribute prototype has changed, ' |
135 self._render_attribute(dispctrl, rschema, value, |
139 'please update %s' % self.__class___, DeprecationWarning) |
136 role=role, table=True) |
140 self._render_attribute(rschema, value, role=role, table=True) |
137 except TypeError: |
141 self.w(u'</table>') |
138 warn('[3.6] _render_attribute prototype has changed, please' |
|
139 ' update %s' % self.__class___, DeprecationWarning) |
|
140 self._render_attribute(rschema, value, role=role, table=True) |
|
141 self.w(u'</table>') |
142 |
142 |
143 def render_entity_relations(self, entity, siderelations=None): |
143 def render_entity_relations(self, entity, siderelations=None): |
144 for rschema, tschemas, role, dispctrl in self._section_def(entity, 'relations'): |
144 for rschema, tschemas, role, dispctrl in self._section_def(entity, 'relations'): |
145 rset = self._relation_rset(entity, rschema, role, dispctrl) |
145 rset = self._relation_rset(entity, rschema, role, dispctrl) |
146 if rset: |
146 if rset: |