fix render (formerly form_render) prototype
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Dec 2009 20:25:58 +0100
changeset 4167 73e649a7797d
parent 4166 677e487e691a
child 4168 9d83f9c80c1c
fix render (formerly form_render) prototype
web/views/editforms.py
web/views/forms.py
web/views/workflow.py
--- a/web/views/editforms.py	Mon Dec 21 20:24:47 2009 +0100
+++ b/web/views/editforms.py	Mon Dec 21 20:25:58 2009 +0100
@@ -320,7 +320,7 @@
                                              entity=entity,
                                              submitmsg=self.submited_message())
         self.init_form(form, entity)
-        self.w(form.render(rendervalues=dict(formvid=u'edition')))
+        self.w(form.render(formvid=u'edition'))
 
     def init_form(self, form, entity):
         """customize your form before rendering here"""
@@ -523,9 +523,8 @@
         except KeyError:
             self._cw.data[countkey] = 1
         self.w(self.form.render(
-            rendervalues=dict(divid=divid, title=title, removejs=removejs,
-                              i18nctx=i18nctx, counter=self._cw.data[countkey]),
-            formvalues=kwargs))
+            divid=divid, title=title, removejs=removejs, i18nctx=i18nctx,
+            counter=self._cw.data[countkey] , **kwargs))
 
     def form_title(self, entity, i18nctx):
         return self._cw.pgettext(i18nctx, 'This %s' % entity.e_schema)
--- a/web/views/forms.py	Mon Dec 21 20:24:47 2009 +0100
+++ b/web/views/forms.py	Mon Dec 21 20:25:58 2009 +0100
@@ -128,11 +128,15 @@
         if self.needs_css:
             self._cw.add_css(self.needs_css)
 
-    def render(self, formvalues=None, rendervalues=None, renderer=None):
+    def render(self, formvalues=None, rendervalues=None, renderer=None, **kwargs):
         """render this form, using the renderer given in args or the default
         FormRenderer()
         """
-        self.build_context(formvalues or {})
+        if rendervalues is not None:
+            warn('[3.6] rendervalues argument is deprecated, all named arguments will be given instead',
+                 DeprecationWarning, stacklevel=1)
+            kwargs = rendervalues
+        self.build_context(formvalues)
         if renderer is None:
             renderer = self.default_renderer()
         return renderer.render(self, kwargs)
@@ -248,6 +252,7 @@
             self.form_renderer_id, self._cw, rset=self.cw_rset, row=self.cw_row,
             col=self.cw_col, entity=self.edited_entity)
 
+    # controller side method (eg POST reception handling)
 
     def actual_eid(self, eid):
         # should be either an int (existant entity) or a variable (to be
--- a/web/views/workflow.py	Mon Dec 21 20:24:47 2009 +0100
+++ b/web/views/workflow.py	Mon Dec 21 20:25:58 2009 +0100
@@ -71,8 +71,7 @@
             'st1': entity.printable_state,
             'st2': self._cw._(transition.destination().name)}
         self.w(u'<p>%s</p>\n' % msg)
-        self.w(form.render(formvalues=dict(wf_info_for=entity.eid,
-                                           by_transition=transition.eid)))
+        self.w(form.render())
 
     def redirectpath(self, entity):
         return entity.rest_path()