changeset 67:5d1e486140ae

Support merging of pdf documents with different names in the uploaded data This is mostly a fix for older python requests versions which don't allow to send several files for one form name.
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 01 Dec 2014 16:04:32 +0100
parents 76838e53434c
children 4645e50539ff
files odfcast/convert.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/odfcast/convert.py	Fri Nov 28 14:58:51 2014 +0100
+++ b/odfcast/convert.py	Mon Dec 01 16:04:32 2014 +0100
@@ -196,7 +196,14 @@
         log.debug("Merging PDF documents")
 
         merger = PdfFileMerger()
-        ffiles = request.files.getlist('files')
+
+        ffiles = []
+
+        # allow files to have arbitray form names
+        # order files by their form names
+        for key, value in sorted(request.files.iterlists(),
+                                 key=lambda x: x[0].lower()):
+            ffiles.extend(value)
 
         for ffile in ffiles:
             try:
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)