refactor to ease overriding tls-sprint
authorsylvain.thenault@logilab.fr
Fri, 17 Apr 2009 13:17:21 +0200
branchtls-sprint
changeset 1396 daaebf6b9922
parent 1393 ff6758d7b96f
child 1397 6cbc7bc8ea6d
refactor to ease overriding
web/views/editforms.py
--- a/web/views/editforms.py	Fri Apr 17 12:13:16 2009 +0200
+++ b/web/views/editforms.py	Fri Apr 17 13:17:21 2009 +0200
@@ -607,12 +607,17 @@
         
     def render_form(self, entity, peid, rtype, role, **kwargs):
         """fetch and render the form"""
-        rschema = self.schema.rschema(rtype)
-        divid = '%s-%s-%s' % (peid, rtype, entity.eid)
-        title = rschema.display_name(self.req, role)
         form = self.vreg.select_object('forms', 'edition', self.req, None,
                                        entity=entity)
+        self.add_hiddens(form, entity, peid, rtype, role)
+        divid = '%s-%s-%s' % (peid, rtype, entity.eid)
+        title = self.schema.rschema(rtype).display_name(self.req, role)
         removejs = self.removejs % (peid, rtype,entity.eid)
+        self.w(form.form_render(renderer=EntityInlinedFormRenderer(), divid=divid,
+                                title=title, removejs=removejs,**kwargs))
+
+    def add_hiddens(self, form, entity, peid, rtype, role):
+        # to ease overriding (see cubes.vcsfile.views.forms for instance)
         if self.keep_entity(entity, peid, rtype):
             if entity.has_eid():
                 rval = entity.eid
@@ -621,9 +626,7 @@
             form.form_add_hidden('edit%s-%s:%s' % (role[0], rtype, peid), rval)
         form.form_add_hidden(name='%s:%s' % (rtype, peid), value=entity.eid,
                              id='rel-%s-%s-%s'  % (peid, rtype, entity.eid))
-        self.w(form.form_render(renderer=EntityInlinedFormRenderer(), divid=divid,
-                                title=title, removejs=removejs,**kwargs))
-
+        
     def keep_entity(self, entity, peid, rtype):
         if not entity.has_eid():
             return True