Hello,
I report this thread to the toscawidgets mailing list because it looks
like I discovered a bug on TW2 FileField Validator.
Read below, and especially at the end where I tested and validated a
workaround based on the use of FormEncode (as it was used with TW1).
Thanks Alessandro for the workaround.
Damien
On 04/26/2012 01:44 AM, Alessandro Molina wrote:
That seems to be a bug in ToscaWidgets2 File Validator.
File should be validated checking the filename as the FieldStorage is
always true.
You can probably send an email to the toscawidgets ml reporting the issue.
In the mean time you should be able to use the
formencode.FieldStorageUploadConverter instead of
tw2.forms.FileValidator as the field validator.
ToscaWidgets2 is compatible with formencode validators.
On Wed, Apr 25, 2012 at 8:53 PM, Damien Accorsi<[email protected]> wrote:
Hello,
I'm using a TW2 form (in Turbogeras 2.1.5) including a FileFied for upload.
The FileField is declared like this:
illus_file_path = tw2f.FileField(label=_("Choose"),
validator=tw2f.FileValidator(required=True))
The validation process always fails. I investiguated and what I found being
really strange is the following code:
def to_python(self, value):
if self.required and (value is None or not value):
raise ValidationError('required', self)
if isinstance(value, basestring) and self.strip:
value = value.strip()
return value
With debug printing, I get the following information:
value = FieldStorage('illus_file_path', u'2011-10-08 18.13.38.jpg')
And not value (which is actually not FieldStorage(...)) return True !!!
import cgi
a = cgi.FieldStorage()
not a
True
Anybody could help / explain me what is wrong?
Damien
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.
A Workaround is to use
formencode.validators.FieldStorageUploadConverter
instead of
tw2.forms.FileValidator
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.