1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
385 It should return a list of tuple (label, value), where value |
385 It should return a list of tuple (label, value), where value |
386 *must be an unicode string*, not a typed value. |
386 *must be an unicode string*, not a typed value. |
387 """ |
387 """ |
388 assert self.choices is not None |
388 assert self.choices is not None |
389 if callable(self.choices): |
389 if callable(self.choices): |
390 try: |
390 if getattr(self.choices, 'im_self', None) is self: |
391 if getattr(self.choices, 'im_self', None) is self: |
391 vocab = self.choices(form=form, **kwargs) |
392 vocab = self.choices(form=form, **kwargs) |
392 elif support_args(self.choices, 'form', 'field'): |
393 else: |
393 vocab = self.choices(form=form, field=self, **kwargs) |
394 vocab = self.choices(form=form, field=self, **kwargs) |
394 else: |
395 except TypeError: |
|
396 try: |
395 try: |
397 vocab = self.choices(form=form, **kwargs) |
396 vocab = self.choices(form=form, **kwargs) |
398 warn('[3.6] %s: choices should now take ' |
397 warn('[3.6] %s: choices should now take ' |
399 'the form and field as named arguments' % self, |
398 'the form and field as named arguments' % self, |
400 DeprecationWarning) |
399 DeprecationWarning) |