web/formfields.py
branchstable
changeset 7572 a554010417ce
parent 7231 18bcb98d129a
child 7574 34154f48d255
equal deleted inserted replaced
7571:6386f802fbc6 7572:a554010417ce
     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
   384         It should return a list of tuple (label, value), where value
   384         It should return a list of tuple (label, value), where value
   385         *must be an unicode string*, not a typed value.
   385         *must be an unicode string*, not a typed value.
   386         """
   386         """
   387         assert self.choices is not None
   387         assert self.choices is not None
   388         if callable(self.choices):
   388         if callable(self.choices):
   389             try:
   389             if getattr(self.choices, 'im_self', None) is self:
   390                 if getattr(self.choices, 'im_self', None) is self:
   390                 vocab = self.choices(form=form, **kwargs)
   391                     vocab = self.choices(form=form, **kwargs)
   391             elif support_args(self.choices, 'form', 'field'):
   392                 else:
   392                 vocab = self.choices(form=form, field=self, **kwargs)
   393                     vocab = self.choices(form=form, field=self, **kwargs)
   393             else:
   394             except TypeError:
       
   395                 try:
   394                 try:
   396                     vocab = self.choices(form=form, **kwargs)
   395                     vocab = self.choices(form=form, **kwargs)
   397                     warn('[3.6]  %s: choices should now take '
   396                     warn('[3.6]  %s: choices should now take '
   398                          'the form and field as named arguments' % self,
   397                          'the form and field as named arguments' % self,
   399                          DeprecationWarning)
   398                          DeprecationWarning)