FileField: Please provide only one value

77 views
Skip to first unread message

Jose Soares

unread,
Mar 19, 2014, 10:36:32 AM3/19/14
to turbo...@googlegroups.com
Hi all,

I'm still migrating from tg1.1 to tg1.5 and today I found a strange
behavior using the FileField widget,
in fact in 1.5 version I can't upload files anymore.
It get me this message:
Please provide only one value


in previous version (1.1) the FileField.value was:

FieldStorage('modello', 'my.odt')

and now it is:

<cherrypy._cpreqbody.Part object at 0xd496450>


What can I do to solve this problem?


Thanks for any help.

j


Jose Soares

unread,
Mar 21, 2014, 5:12:34 AM3/21/14
to turbo...@googlegroups.com
I think I have solved the problem.
While I dug in the library sources I found this code in
formencode/schema.py:

# are iterators (list, tuple, set, etc) allowed?
if self._value_is_iterator(value) and not
getattr(validator, 'accept_iterator', False):
errors[name] =
Invalid(self.message('singleValueExpected', state),
value_dict, state)

so I deduced that the validator FileField must have the parameter
accept_iterator=True

as in:

w.FileField(name='modello',
validator=v.FieldStorageUploadConverter(accept_iterator=True))
and now it works.
j
Reply all
Reply to author
Forward
0 new messages