don't use reledit for composite relations stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 29 Jun 2009 16:09:08 +0200
branchstable
changeset 2189 08c66a83c3ca
parent 2188 3a57c8173290
child 2190 d9f5fd1879fc
don't use reledit for composite relations
web/views/primary.py
--- a/web/views/primary.py	Mon Jun 29 16:06:48 2009 +0200
+++ b/web/views/primary.py	Mon Jun 29 16:09:08 2009 +0200
@@ -115,7 +115,19 @@
 
     def render_entity_attributes(self, entity, siderelations=None):
         for rschema, tschemas, role, dispctrl in self._section_def(entity, 'attributes'):
-            vid =  dispctrl.get('vid', 'reledit')
+            # don't use reledit as default vid for composite relation
+            if rschema.is_final():
+                defaultvid = 'reledit'
+            # XXX use entity.e_schema.role_rproperty(role, rschema, 'composite', tschemas[0]) once yams > 0.23.0 is out
+            elif role == 'subject' and \
+                 rschema.rproperty(entity.e_schema, tschemas[0], 'composite'):
+                defaultvid = 'csv'
+            elif role == 'object' and \
+                 rschema.rproperty(tschemas[0], entity.e_schema, 'composite'):
+                defaultvid = 'csv'
+            else:
+                defaultvid = 'reledit'
+            vid =  dispctrl.get('vid', defaultvid)
             if rschema.is_final() or vid == 'reledit':
                 value = entity.view(vid, rtype=rschema.type, role=role)
             else: