Commits

Anonymous committed 5d83c8c

Changed file upload behavior: when a file is being uploaded, CP passes directly the cgi.FieldStorage instance to the method, instead of reading the file in a string and passing that string. Useful attributes are: file, filename, type

  • Participants
  • Parent commits b41533a

Comments (0)

Files changed (4)

cherrypy/_cphttptools.py

         cpg.request.remoteAddr = clientAddress
         cpg.request.remoteHost = remoteHost
         cpg.request.paramList = [] # Only used for Xml-Rpc
-        cpg.request.filenameMap = {}
-        cpg.request.fileTypeMap = {}
         cpg.request.headerMap = {}
         cpg.request.requestLine = requestLine
         cpg.request.simpleCookie = Cookie.SimpleCookie()
             valueList = forms[key]
             if isinstance(valueList, list):
                 cpg.request.paramMap[key] = []
-                cpg.request.filenameMap[key] = []
-                cpg.request.fileTypeMap[key] = []
                 for item in valueList:
-                    cpg.request.paramMap[key].append(item.value)
-                    cpg.request.filenameMap[key].append(item.filename)
-                    cpg.request.fileTypeMap[key].append(item.type)
+                    cpg.request.paramMap[key].append(item)
             else:
-                cpg.request.paramMap[key] = valueList.value
-                cpg.request.filenameMap[key] = valueList.filename
-                cpg.request.fileTypeMap[key] = valueList.type
+                cpg.request.paramMap[key] = valueList
 
 
 # Error handling

cherrypy/lib/filter/decodingfilter.py

         
         enc = cpg.config.get('decodingFilter.encoding', 'utf-8')
         for key, value in cpg.request.paramMap.items():
-            if cpg.request.filenameMap.get(key):
+            if hasattr(value, 'file'):
                 # This is a file being uploaded: skip it
                 continue
             if isinstance(value, list):

cherrypy/test/helper.py

     else:
         if not port_is_free():
             raise IOError("Port %s is in use; perhaps the previous server "
-                          "did not shut down properly." % port)
+                          "did not shut down properly." % PORT)
         t = threading.Thread(target=cpg.server.start, args=(False, serverClass))
         t.start()
         time.sleep(1)

cherrypy/tutorial/tut11_file_upload.py

             myFile filename: %s<br />
             myFile mime-type: %s
         </body></html>
-        """ % (len(myFile),
-               cpg.request.filenameMap['myFile'],
-               cpg.request.fileTypeMap['myFile'])
+        """ % (len(myFile.value),
+               myFile.filename,
+               myFile.type)
     upload.exposed = True