Don't process file for new batch unless field is present
This commit is contained in:
parent
737b2e578a
commit
aded59d7ff
|
@ -129,16 +129,17 @@ class BatchMasterView3(MasterView3, BatchMasterView2):
|
|||
kwargs = self.get_batch_kwargs(batch)
|
||||
|
||||
# TODO: this needs work yet surely...
|
||||
filedict = kwargs.pop('filename', None)
|
||||
filepath = None
|
||||
if filedict:
|
||||
kwargs['filename'] = '' # null not allowed
|
||||
tempdir = tempfile.mkdtemp()
|
||||
filepath = os.path.join(tempdir, filedict['filename'])
|
||||
tmpinfo = form.deform_form['filename'].widget.tmpstore.get(filedict['uid'])
|
||||
tmpdata = tmpinfo['fp'].read()
|
||||
with open(filepath, 'wb') as f:
|
||||
f.write(tmpdata)
|
||||
if 'filename' in form.schema:
|
||||
filedict = kwargs.pop('filename', None)
|
||||
filepath = None
|
||||
if filedict:
|
||||
kwargs['filename'] = '' # null not allowed
|
||||
tempdir = tempfile.mkdtemp()
|
||||
filepath = os.path.join(tempdir, filedict['filename'])
|
||||
tmpinfo = form.deform_form['filename'].widget.tmpstore.get(filedict['uid'])
|
||||
tmpdata = tmpinfo['fp'].read()
|
||||
with open(filepath, 'wb') as f:
|
||||
f.write(tmpdata)
|
||||
|
||||
# TODO: is this still necessary with colander?
|
||||
# destroy initial batch and re-make using handler
|
||||
|
@ -150,10 +151,11 @@ class BatchMasterView3(MasterView3, BatchMasterView2):
|
|||
|
||||
# TODO: this needs work yet surely...
|
||||
# if batch has input data file, let handler properly establish that
|
||||
if filedict:
|
||||
self.handler.set_input_file(batch, filepath)
|
||||
os.remove(filepath)
|
||||
os.rmdir(tempdir)
|
||||
if 'filename' in form.schema:
|
||||
if filedict:
|
||||
self.handler.set_input_file(batch, filepath)
|
||||
os.remove(filepath)
|
||||
os.rmdir(tempdir)
|
||||
|
||||
return batch
|
||||
|
||||
|
|
Loading…
Reference in a new issue