equal
deleted
inserted
replaced
286 except TypeError: |
286 except TypeError: |
287 warn('[3.3] vocabulary method (eg field.choices) should now take ' |
287 warn('[3.3] vocabulary method (eg field.choices) should now take ' |
288 'the form instance as argument', DeprecationWarning) |
288 'the form instance as argument', DeprecationWarning) |
289 vocab = self.choices(req=form._cw) |
289 vocab = self.choices(req=form._cw) |
290 else: |
290 else: |
291 vocab = form.form_field_vocabulary(self) |
291 vocab = self.choices |
|
292 if vocab and not isinstance(vocab[0], (list, tuple)): |
|
293 vocab = [(x, x) for x in vocab] |
292 if self.internationalizable: |
294 if self.internationalizable: |
293 # the short-cirtcuit 'and' boolean operator is used here to permit |
295 # the short-cirtcuit 'and' boolean operator is used here to permit |
294 # a valid empty string in vocabulary without attempting to translate |
296 # a valid empty string in vocabulary without attempting to translate |
295 # it by gettext (which can lead to weird strings display) |
297 # it by gettext (which can lead to weird strings display) |
296 vocab = [(label and form._cw._(label), value) for label, value in vocab] |
298 vocab = [(label and form._cw._(label), value) for label, value in vocab] |
548 value = None |
550 value = None |
549 else: |
551 else: |
550 value = posted.get(self.input_name(form)) |
552 value = posted.get(self.input_name(form)) |
551 # no need to check value when nor explicit detach nor new file |
553 # no need to check value when nor explicit detach nor new file |
552 # submitted, since it will think the attribute is not modified |
554 # submitted, since it will think the attribute is not modified |
553 elif value: |
555 if value: |
554 filename, _, stream = value |
556 filename, _, stream = value |
555 # value is a 3-uple (filename, mimetype, stream) |
557 # value is a 3-uple (filename, mimetype, stream) |
556 value = Binary(stream.read()) |
558 value = Binary(stream.read()) |
557 if not val.getvalue(): # usually an unexistant file |
559 if not val.getvalue(): # usually an unexistant file |
558 value = None |
560 value = None |