cleanup, remove some unnecessary (sometime buggy) stuff tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 08 Apr 2009 20:36:11 +0200
branchtls-sprint
changeset 1305 395ef7f2b95b
parent 1304 8975c8e520a9
child 1306 e70ad982374a
cleanup, remove some unnecessary (sometime buggy) stuff
web/form.py
web/formfields.py
web/formrenderers.py
web/views/editforms.py
web/views/workflow.py
--- a/web/form.py	Wed Apr 08 20:34:26 2009 +0200
+++ b/web/form.py	Wed Apr 08 20:36:11 2009 +0200
@@ -81,23 +81,6 @@
         if self.force_display:
             return None
         return self.maxrelitems + 1
-
-    def need_multipart(self, entity, categories=('primary', 'secondary')):
-        """return a boolean indicating if form's enctype should be multipart
-        """
-        for rschema, _, x in entity.relations_by_category(categories):
-            if entity.get_widget(rschema, x).need_multipart:
-                return True
-        # let's find if any of our inlined entities needs multipart
-        for rschema, targettypes, x in entity.relations_by_category('inlineview'):
-            assert len(targettypes) == 1, \
-                   "I'm not able to deal with several targets and inlineview"
-            ttype = targettypes[0]
-            inlined_entity = self.vreg.etype_class(ttype)(self.req, None, None)
-            for irschema, _, x in inlined_entity.relations_by_category(categories):
-                if inlined_entity.get_widget(irschema, x).need_multipart:
-                    return True
-        return False
     
     def initialize_varmaker(self):
         varmaker = self.req.get_page_data('rql_varmaker')
@@ -140,6 +123,24 @@
         return self.button(label, type=type, **kwargs)
 
     # XXX deprecated with new form system
+
+    def need_multipart(self, entity, categories=('primary', 'secondary')):
+        """return a boolean indicating if form's enctype should be multipart
+        """
+        for rschema, _, x in entity.relations_by_category(categories):
+            if entity.get_widget(rschema, x).need_multipart:
+                return True
+        # let's find if any of our inlined entities needs multipart
+        for rschema, targettypes, x in entity.relations_by_category('inlineview'):
+            assert len(targettypes) == 1, \
+                   "I'm not able to deal with several targets and inlineview"
+            ttype = targettypes[0]
+            inlined_entity = self.vreg.etype_class(ttype)(self.req, None, None)
+            for irschema, _, x in inlined_entity.relations_by_category(categories):
+                if inlined_entity.get_widget(irschema, x).need_multipart:
+                    return True
+        return False
+    
     def error_message(self):
         """return formatted error message
 
--- a/web/formfields.py	Wed Apr 08 20:34:26 2009 +0200
+++ b/web/formfields.py	Wed Apr 08 20:36:11 2009 +0200
@@ -326,7 +326,6 @@
         self.min = min
         self.max = max
 
-
 class BooleanField(Field):
     widget = Radio
         
@@ -368,9 +367,8 @@
 
 class HiddenInitialValueField(Field):
     def __init__(self, visible_field, name):
-        super(HiddenInitialValueField, self).__init__(name=name,
-                                                      widget=HiddenInput,
-                                                      eidparam=True)
+        super(HiddenInitialValueField, self).__init__(
+            name=name, widget=HiddenInput, eidparam=True)
         self.visible_field = visible_field
     
                  
--- a/web/formrenderers.py	Wed Apr 08 20:34:26 2009 +0200
+++ b/web/formrenderers.py	Wed Apr 08 20:36:11 2009 +0200
@@ -303,7 +303,8 @@
         w(u'<tr id="relationSelectorRow_%s" class="separator">' % eid)
         w(u'<th class="labelCol">')
         w(u'<span>%s</span>' % _('add relation'))
-        w(u'<select id="relationSelector_%s" tabindex="%s" onchange="javascript:showMatchingSelect(this.options[this.selectedIndex].value,%s);">'
+        w(u'<select id="relationSelector_%s" tabindex="%s" '
+          'onchange="javascript:showMatchingSelect(this.options[this.selectedIndex].value,%s);">'
           % (eid, req.next_tabindex(), html_escape(dumps(eid))))
         w(u'<option value="">%s</option>' % _('select a relation'))
         for i18nrtype, rschema, target in srels_by_cat:
--- a/web/views/editforms.py	Wed Apr 08 20:34:26 2009 +0200
+++ b/web/views/editforms.py	Wed Apr 08 20:36:11 2009 +0200
@@ -48,8 +48,6 @@
     """form used to confirm deletion of some entities"""
     id = 'deleteconf'
     title = _('delete')
-    domid = 'deleteconf'
-    onsubmit = None
     # don't use navigation, all entities asked to be deleted should be displayed
     # else we will only delete the displayed page
     need_navigation = False
@@ -439,7 +437,7 @@
         self.form_title(entity)
         form = self.vreg.select_object('forms', 'edition', self.req, entity.rset,
                                        row=entity.row, col=entity.col, entity=entity,
-                                       domid=self.id, submitmsg=self.submited_message())
+                                       submitmsg=self.submited_message())
         self.init_form(form, entity)
         self.w(form.form_render(renderer=EntityFormRenderer(), formvid=u'edition'))
 
@@ -546,8 +544,7 @@
         super(TableEditForm, self).__init__(*args, **kwargs)
         for row in xrange(len(self.rset)):
             form = self.vreg.select_object('forms', 'edition', self.req, self.rset,
-                                           row=row, domid=self.id,
-                                           attrcategories=('primary',),
+                                           row=row, attrcategories=('primary',),
                                            set_error_url=False)
             # XXX rely on the MultipleEntityFormRenderer to put the eid input
             form.remove_field(form.field_by_name('eid'))
@@ -564,8 +561,7 @@
         should be the eid
         """
         #self.form_title(entity)
-        form = self.vreg.select_object('forms', self.id, self.req, self.rset,
-                                       domid=self.id)
+        form = self.vreg.select_object('forms', self.id, self.req, self.rset)
         self.w(form.form_render(renderer=EntityCompositeFormRenderer()))
 
 
--- a/web/views/workflow.py	Wed Apr 08 20:34:26 2009 +0200
+++ b/web/views/workflow.py	Wed Apr 08 20:36:11 2009 +0200
@@ -34,7 +34,8 @@
 class ChangeStateForm(form.EntityFieldsForm):
     id = 'changestate'
     
-    __method = StringField(name='__method', initial='set_state', widget=HiddenInput)
+    __method = StringField(name='__method', initial='set_state',
+                           widget=HiddenInput)
     state = StringField(widget=HiddenInput, eidparam=True)
     trcomment = RichTextField(eidparam=True)
     form_buttons = [SubmitButton(stdmsgs.YES),
@@ -52,10 +53,13 @@
         transition = self.req.eid_rset(self.req.form['treid']).get_entity(0, 0)
         dest = transition.destination()
         _ = self.req._
-        form = self.vreg.select_object('forms', 'changestate', self.req, self.rset, row=row, col=col,
-                                       entity=entity, redirect_path=self.redirectpath(entity))
+        form = self.vreg.select_object('forms', 'changestate', self.req,
+                                       self.rset, row=row, col=col,
+                                       entity=entity,
+                                       redirect_path=self.redirectpath(entity))
         self.w(form.error_message())
-        self.w(u'<h4>%s %s</h4>\n' % (_(transition.name), entity.view('oneline')))
+        self.w(u'<h4>%s %s</h4>\n' % (_(transition.name),
+                                      entity.view('oneline')))
         msg = _('status will change from %(st1)s to %(st2)s') % {
             'st1': _(state.name),
             'st2': _(dest.name)}