[wsgi] fix handling of multiple posted files
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 08 Feb 2016 16:39:51 +0100
changeset 11154 221febada1e8
parent 11153 e48db902af71
child 11155 3bc47295c262
[wsgi] fix handling of multiple posted files We were only keeping the last received file.
cubicweb/wsgi/request.py
--- a/cubicweb/wsgi/request.py	Fri Feb 05 18:23:00 2016 +0100
+++ b/cubicweb/wsgi/request.py	Mon Feb 08 16:39:51 2016 +0100
@@ -81,8 +81,12 @@
                                                   headers= headers_in)
         self.content = environ['wsgi.input']
         if files is not None:
-            for key, part in files.items():
-                self.form[key] = (part.filename, part.file)
+            for key, part in files.iterallitems():
+                self.form.setdefault(key, []).append((part.filename, part.file))
+            # 3.16.4 backward compat
+            for key in files.keys():
+                if len(self.form[key]) == 1:
+                    self.form[key] = self.form[key][0]
 
     def __repr__(self):
         # Since this is called as part of error handling, we need to be very