From 57de1bd900c2e75d2400b67e523dd33babf173e1 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Thu, 2 Jul 2015 08:10:01 +0200 Subject: [PATCH] Raise ValidationError instead of returning None if a file upload was invalid. --- src/formdefinition.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/formdefinition.py b/src/formdefinition.py index ce9607e..4025510 100644 --- a/src/formdefinition.py +++ b/src/formdefinition.py @@ -227,8 +227,9 @@ class FormDefinition(object): """ try: value = form_values[field_def['name']] - except KeyError: - return None + except KeyError, err: + raise ValidationError("Invalid file upload") + field_name = field_def['name'] upload_fname = form_values[u'{0}__name'.format(field_name)] upload_fname_ext = os.path.splitext(upload_fname)[-1].lstrip('.')