vocabulary method (eg field.choices) should now take the form instance as argument stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 29 Jun 2009 17:14:05 +0200
branchstable
changeset 2196 b08521e4eaab
parent 2195 58bef4f707ce
child 2197 397e3e4583f7
vocabulary method (eg field.choices) should now take the form instance as argument
web/formfields.py
--- a/web/formfields.py	Mon Jun 29 17:02:51 2009 +0200
+++ b/web/formfields.py	Mon Jun 29 17:14:05 2009 +0200
@@ -164,7 +164,12 @@
         widgets which desire it."""
         if self.choices is not None:
             if callable(self.choices):
-                vocab = self.choices(req=form.req)
+                try:
+                    vocab = self.choices(form=form)
+                except TypeError:
+                    warn('vocabulary method (eg field.choices) should now take '
+                         'the form instance as argument', DeprecationWarning)
+                    vocab = self.choices(req=form.req)
             else:
                 vocab = self.choices
             if vocab and not isinstance(vocab[0], (list, tuple)):