[form] replace is_subform by parent_form, carrying more information at the same cost stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 29 Sep 2009 12:41:46 +0200
branchstable
changeset 3513 c002f6488631
parent 3512 2ceaa4e40348
child 3514 1531edc6c021
[form] replace is_subform by parent_form, carrying more information at the same cost
web/views/cwproperties.py
web/views/editforms.py
web/views/formrenderers.py
web/views/forms.py
web/views/workflow.py
--- a/web/views/cwproperties.py	Tue Sep 29 12:39:32 2009 +0200
+++ b/web/views/cwproperties.py	Tue Sep 29 12:41:46 2009 +0200
@@ -216,7 +216,7 @@
                                                 eidparam=True))
         subform.vreg = self.vreg
         subform.form_add_hidden('pkey', key, eidparam=True)
-        form.form_add_subform(subform)
+        form.add_subform(subform)
         return subform
 
 
--- a/web/views/editforms.py	Tue Sep 29 12:39:32 2009 +0200
+++ b/web/views/editforms.py	Tue Sep 29 12:41:46 2009 +0200
@@ -65,7 +65,7 @@
             done.add(entity.eid)
             subform = self.vreg['forms'].select('base', self.req, entity=entity,
                                                 mainform=False)
-            self.form_add_subform(subform)
+            self.add_subform(subform)
 
 
 class DeleteConfFormView(FormViewMixIn, EntityView):
@@ -421,7 +421,7 @@
                                              mainform=False)
             # XXX rely on the EntityCompositeFormRenderer to put the eid input
             form.remove_field(form.field_by_name('eid'))
-            self.form_add_subform(form)
+            self.add_subform(form)
 
 
 class TableEditFormView(FormViewMixIn, EntityView):
--- a/web/views/formrenderers.py	Tue Sep 29 12:39:32 2009 +0200
+++ b/web/views/formrenderers.py	Tue Sep 29 12:41:46 2009 +0200
@@ -311,7 +311,7 @@
     _main_display_fields = None
 
     def render_fields(self, w, form, values):
-        if not form.is_subform:
+        if form.parent_form is None:
             w(u'<table class="listing">')
             subfields = [field for field in form.forms[0].fields
                          if self.display_field(form, field)
@@ -327,14 +327,14 @@
                     w(u'<th>%s</th>' % self.req._(field.label))
                 w(u'</tr>')
         super(EntityCompositeFormRenderer, self).render_fields(w, form, values)
-        if not form.is_subform:
+        if form.parent_form is None:
             w(u'</table>')
             if self._main_display_fields:
                 super(EntityCompositeFormRenderer, self)._render_fields(
                     self._main_display_fields, w, form)
 
     def _render_fields(self, fields, w, form):
-        if form.is_subform:
+        if form.parent_form is not None:
             entity = form.edited_entity
             values = form.form_previous_values
             qeid = eid_param('eid', entity.eid)
--- a/web/views/forms.py	Tue Sep 29 12:39:32 2009 +0200
+++ b/web/views/forms.py	Tue Sep 29 12:41:46 2009 +0200
@@ -55,7 +55,6 @@
     """
     id = 'base'
 
-    is_subform = False
     internal_fields = ('__errorurl',) + NAV_FORM_PARAMETERS
 
     # attributes overrideable by subclasses or through __init__
@@ -506,9 +505,9 @@
         super(CompositeFormMixIn, self).__init__(*args, **kwargs)
         self.forms = []
 
-    def form_add_subform(self, subform):
+    def add_subform(self, subform):
         """mark given form as a subform and append it"""
-        subform.is_subform = True
+        subform.parent_form = self
         self.forms.append(subform)
 
     def build_context(self, rendervalues=None):
--- a/web/views/workflow.py	Tue Sep 29 12:39:32 2009 +0200
+++ b/web/views/workflow.py	Tue Sep 29 12:41:46 2009 +0200
@@ -84,7 +84,7 @@
         subform = self.vreg['forms'].select('edition', self.req, entity=trinfo,
                                             mainform=False)
         subform.field_by_name('by_transition').widget = fwdgs.HiddenInput()
-        form.form_add_subform(subform)
+        form.add_subform(subform)
         self.w(form.form_render(wf_info_for=entity.eid,
                                 by_transition=transition.eid))