web/formfields.py
branchstable
changeset 2196 b08521e4eaab
parent 2146 6645e18e8c93
child 2244 52e2431e7cce
equal deleted inserted replaced
2195:58bef4f707ce 2196:b08521e4eaab
   162     def vocabulary(self, form):
   162     def vocabulary(self, form):
   163         """return vocabulary for this field. This method will be called by
   163         """return vocabulary for this field. This method will be called by
   164         widgets which desire it."""
   164         widgets which desire it."""
   165         if self.choices is not None:
   165         if self.choices is not None:
   166             if callable(self.choices):
   166             if callable(self.choices):
   167                 vocab = self.choices(req=form.req)
   167                 try:
       
   168                     vocab = self.choices(form=form)
       
   169                 except TypeError:
       
   170                     warn('vocabulary method (eg field.choices) should now take '
       
   171                          'the form instance as argument', DeprecationWarning)
       
   172                     vocab = self.choices(req=form.req)
   168             else:
   173             else:
   169                 vocab = self.choices
   174                 vocab = self.choices
   170             if vocab and not isinstance(vocab[0], (list, tuple)):
   175             if vocab and not isinstance(vocab[0], (list, tuple)):
   171                 vocab = [(x, x) for x in vocab]
   176                 vocab = [(x, x) for x in vocab]
   172         else:
   177         else: