Skip to content

Commit

Permalink
Check for filename of FieldStorage. Fixes #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed May 18, 2012
1 parent db23a9a commit 4921e0c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tw2/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ class FileValidator(twc.Validator):

def validate_python(self, value, outer_call=None):
if isinstance(value, cgi.FieldStorage):
if self.required and not getattr(value, 'filename', None):
raise twc.ValidationError('required', self)

if self.extension is not None and \
not value.filename.endswith(self.extension):
raise twc.ValidationError('badext', self)
Expand Down

0 comments on commit 4921e0c

Please sign in to comment.