[forms] fix backward compat for field.choices arguments
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 27 Jan 2010 09:25:40 +0100
changeset 4386 cf8842b69379
parent 4385 820aa03f71ad
child 4387 4aacd6492ef4
[forms] fix backward compat for field.choices arguments
web/formfields.py
--- a/web/formfields.py	Wed Jan 27 09:24:35 2010 +0100
+++ b/web/formfields.py	Wed Jan 27 09:25:40 2010 +0100
@@ -264,12 +264,15 @@
                     vocab = self.choices(form=form, field=self)
             except TypeError:
                 warn('[3.6]  %s: choices should now take '
-                     'the form and field as named arguments', self)
+                     'the form and field as named arguments' % self,
+                     DeprecationWarning)
                 try:
-                    vocab = self.choices(req=form._cw)
+                    vocab = self.choices(form=form)
                 except TypeError:
                     warn('[3.3]  %s: choices should now take '
-                         'the form and field as named arguments', self)
+                         'the form and field as named arguments' % self,
+                         DeprecationWarning)
+                    vocab = self.choices(req=form._cw)
         else:
             vocab = self.choices
         if vocab and not isinstance(vocab[0], (list, tuple)):