[primary] handle final relation (eg attribute) in the relations section, and give dispctrl to view's extra kwargs as for non final relation stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 10 Aug 2010 14:21:32 +0200
branchstable
changeset 6086 2b53a8669c98
parent 6085 8a059eefac75
child 6087 bdfbd6aa5758
[primary] handle final relation (eg attribute) in the relations section, and give dispctrl to view's extra kwargs as for non final relation
web/views/primary.py
--- a/web/views/primary.py	Tue Aug 10 14:20:21 2010 +0200
+++ b/web/views/primary.py	Tue Aug 10 14:21:32 2010 +0200
@@ -130,7 +130,8 @@
         for rschema, _, role, dispctrl in self._section_def(entity, 'attributes'):
             vid = dispctrl.get('vid', 'reledit')
             if rschema.final or vid == 'reledit' or dispctrl.get('rtypevid'):
-                value = entity.view(vid, rtype=rschema.type, role=role)
+                value = entity.view(vid, rtype=rschema.type, role=role,
+                                    initargs={'dispctrl': dispctrl})
             else:
                 rset = self._relation_rset(entity, rschema, role, dispctrl)
                 if rset:
@@ -153,6 +154,16 @@
 
     def render_entity_relations(self, entity):
         for rschema, tschemas, role, dispctrl in self._section_def(entity, 'relations'):
+            if rschema.final:
+                self.w(u'<div class="section">')
+                label = self._rel_label(entity, rschema, role, dispctrl)
+                if label:
+                    self.w(u'<h4>%s</h4>' % label)
+                vid = dispctrl.get('vid', 'reledit')
+                entity.view(vid, rtype=rschema.type, role=role, w=self.w,
+                            initargs={'dispctrl': dispctrl})
+                self.w(u'</div>')
+                continue
             rset = self._relation_rset(entity, rschema, role, dispctrl)
             if rset:
                 try: