Don't raise KeyError if a non-required file wasn't uploaded.

pull/7/head
Ferry Boender 10 years ago
parent 24f9a25f54
commit 0eb04cae51
  1. 5
      examples/megacorp_acc/job_import_employees.sh
  2. 5
      src/formdefinition.py

@ -1,5 +1,10 @@
#!/bin/sh #!/bin/sh
if [ -z "$csv_file" ]; then
echo "No file specified" >&2
exit 1
fi
{ {
echo ".separator ," echo ".separator ,"
echo ".import $csv_file employee" echo ".import $csv_file employee"

@ -225,7 +225,10 @@ class FormDefinition(object):
""" """
Validate a form field of type 'file'. Validate a form field of type 'file'.
""" """
value = form_values[field_def['name']] try:
value = form_values[field_def['name']]
except KeyError:
return None
field_name = field_def['name'] field_name = field_def['name']
upload_fname = form_values[u'{0}__name'.format(field_name)] upload_fname = form_values[u'{0}__name'.format(field_name)]
upload_fname_ext = os.path.splitext(upload_fname)[-1].lstrip('.') upload_fname_ext = os.path.splitext(upload_fname)[-1].lstrip('.')

Loading…
Cancel
Save