web/formfields.py
changeset 6225 a176e68b7d0d
parent 6142 8bc6eac1fac1
parent 6218 d37428222a63
child 6333 e3994fcc21c3
equal deleted inserted replaced
6182:30de0be8f895 6225:a176e68b7d0d
   414             vocab = [(label and form._cw._(label), value)
   414             vocab = [(label and form._cw._(label), value)
   415                      for label, value in vocab]
   415                      for label, value in vocab]
   416         if self.sort:
   416         if self.sort:
   417             vocab = vocab_sort(vocab)
   417             vocab = vocab_sort(vocab)
   418         # XXX pre 3.9 bw compat
   418         # XXX pre 3.9 bw compat
   419         for i, (label, value) in enumerate(vocab):
   419         for i, option in enumerate(vocab):
       
   420             # option may be a 2 or 3-uple (see Select widget _render method for
       
   421             # explanation)
       
   422             value = option[1]
   420             if value is not None and not isinstance(value, basestring):
   423             if value is not None and not isinstance(value, basestring):
   421                 warn('[3.9] %s: vocabulary value should be an unicode string'
   424                 warn('[3.9] %s: vocabulary value should be an unicode string'
   422                      % self, DeprecationWarning)
   425                      % self, DeprecationWarning)
   423                 vocab[i] = (label, unicode(value))
   426                 option = list(option)
       
   427                 option[1] = unicode(value)
       
   428                 vocab[i] = option
   424         return vocab
   429         return vocab
   425 
   430 
   426     def format(self, form):
   431     def format(self, form):
   427         """return MIME type used for the given (text or bytes) field"""
   432         """return MIME type used for the given (text or bytes) field"""
   428         if self.eidparam and self.role == 'subject':
   433         if self.eidparam and self.role == 'subject':