# HG changeset patch # User Sylvain Thénault # Date 1264443395 -3600 # Node ID 0eb7efcbcee1f9696e552e7d9b05d63dbfe38f99 # Parent 27ea69e2cfeab56331c0ec132717a191bb052773 to ease overriding of field.choices using *function* (set using autoform_field_kwargs), give the field as named argument diff -r 27ea69e2cfea -r 0eb7efcbcee1 web/formfields.py --- a/web/formfields.py Mon Jan 25 19:13:17 2010 +0100 +++ b/web/formfields.py Mon Jan 25 19:16:35 2010 +0100 @@ -255,11 +255,18 @@ assert self.choices is not None if callable(self.choices): try: - vocab = self.choices(form=form) + if getattr(self.choices, 'im_self', None) is self: + vocab = self.choices(form=form) + else: + vocab = self.choices(form=form, field=self) except TypeError: - warn('[3.3] vocabulary method (eg field.choices) should now take ' - 'the form instance as argument', DeprecationWarning) - vocab = self.choices(req=form._cw) + warn('[3.6] %s: choices should now take ' + 'the form and field as named arguments', self) + try: + vocab = self.choices(req=form._cw) + except TypeError: + warn('[3.3] %s: choices should now take ' + 'the form and field as named arguments', self) else: vocab = self.choices if vocab and not isinstance(vocab[0], (list, tuple)):