consider 'rvid' key in primaryview_display_control to determine sub-view to use in reledit stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 27 Nov 2009 10:24:13 +0100
branchstable
changeset 3927 b2a6c25b8429
parent 3926 0585694c1896
child 3928 2ced335a9b55
consider 'rvid' key in primaryview_display_control to determine sub-view to use in reledit
web/views/editforms.py
--- a/web/views/editforms.py	Fri Nov 27 10:23:11 2009 +0100
+++ b/web/views/editforms.py	Fri Nov 27 10:24:13 2009 +0100
@@ -28,6 +28,7 @@
 from cubicweb.web.formwidgets import Button, SubmitButton, ResetButton
 from cubicweb.web.views import forms
 
+_pvdc = uicfg.primaryview_display_ctrl
 
 def relation_id(eid, rtype, role, reid):
     """return an identifier for a relation between two entities"""
@@ -150,8 +151,7 @@
             self.relation_form(lzone, value, form,
                                self._build_renderer(entity, rtype, role))
         else:
-            if rvid is None:
-                rvid = self._compute_best_vid(entity.e_schema, rschema, role)
+            rvid = self._compute_best_vid(entity.e_schema, rschema, role)
             rset = entity.related(rtype, role)
             if rset:
                 value = self.view(rvid, rset)
@@ -212,6 +212,9 @@
         w(u'</div>')
 
     def _compute_best_vid(self, eschema, rschema, role):
+        dispctrl = _pvdc.etype_get(eschema, rschema, role)
+        if dispctrl.get('rvid'):
+            return dispctrl['rvid']
         if eschema.cardinality(rschema, role) in '+*':
             return self._many_rvid
         return self._one_rvid
@@ -277,7 +280,7 @@
         eschema = entity.e_schema
         rtype = str(rschema)
         # XXX check autoform_section. what if 'generic'?
-        dispctrl = uicfg.primaryview_display_ctrl.etype_get(eschema, rtype, role)
+        dispctrl = _pvdc.etype_get(eschema, rtype, role)
         vid = dispctrl.get('vid', 'reledit')
         if vid != 'reledit': # reledit explicitly disabled
             return False