web/formfields.py
branchstable
changeset 6218 d37428222a63
parent 6114 3e1718a2db55
child 6225 a176e68b7d0d
child 6285 b8a2c9b9a2cb
equal deleted inserted replaced
6217:e2aeb40d5983 6218:d37428222a63
   408             vocab = [(label and form._cw._(label), value)
   408             vocab = [(label and form._cw._(label), value)
   409                      for label, value in vocab]
   409                      for label, value in vocab]
   410         if self.sort:
   410         if self.sort:
   411             vocab = vocab_sort(vocab)
   411             vocab = vocab_sort(vocab)
   412         # XXX pre 3.9 bw compat
   412         # XXX pre 3.9 bw compat
   413         for i, (label, value) in enumerate(vocab):
   413         for i, option in enumerate(vocab):
       
   414             # option may be a 2 or 3-uple (see Select widget _render method for
       
   415             # explanation)
       
   416             value = option[1]
   414             if value is not None and not isinstance(value, basestring):
   417             if value is not None and not isinstance(value, basestring):
   415                 warn('[3.9] %s: vocabulary value should be an unicode string'
   418                 warn('[3.9] %s: vocabulary value should be an unicode string'
   416                      % self, DeprecationWarning)
   419                      % self, DeprecationWarning)
   417                 vocab[i] = (label, unicode(value))
   420                 option = list(option)
       
   421                 option[1] = unicode(value)
       
   422                 vocab[i] = option
   418         return vocab
   423         return vocab
   419 
   424 
   420     def format(self, form):
   425     def format(self, form):
   421         """return MIME type used for the given (text or bytes) field"""
   426         """return MIME type used for the given (text or bytes) field"""
   422         if self.eidparam and self.role == 'subject':
   427         if self.eidparam and self.role == 'subject':