Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 323

Show
Ignore:
Timestamp:
06/16/05 08:03:39
Author:
rdelon
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cphttptools.py

    r321 r323  
    120120        cpg.request.remoteHost = remoteHost 
    121121        cpg.request.paramList = [] # Only used for Xml-Rpc 
    122         cpg.request.filenameMap = {} 
    123         cpg.request.fileTypeMap = {} 
    124122        cpg.request.headerMap = {} 
    125123        cpg.request.requestLine = requestLine 
     
    242240            if isinstance(valueList, list): 
    243241                cpg.request.paramMap[key] = [] 
    244                 cpg.request.filenameMap[key] = [] 
    245                 cpg.request.fileTypeMap[key] = [] 
    246242                for item in valueList: 
    247                     cpg.request.paramMap[key].append(item.value) 
    248                     cpg.request.filenameMap[key].append(item.filename) 
    249                     cpg.request.fileTypeMap[key].append(item.type) 
     243                    cpg.request.paramMap[key].append(item) 
    250244            else: 
    251                 cpg.request.paramMap[key] = valueList.value 
    252                 cpg.request.filenameMap[key] = valueList.filename 
    253                 cpg.request.fileTypeMap[key] = valueList.type 
     245                cpg.request.paramMap[key] = valueList 
    254246 
    255247 
  • trunk/cherrypy/lib/filter/decodingfilter.py

    r230 r323  
    4343        enc = cpg.config.get('decodingFilter.encoding', 'utf-8') 
    4444        for key, value in cpg.request.paramMap.items(): 
    45             if cpg.request.filenameMap.get(key): 
     45            if hasattr(value, 'file'): 
    4646                # This is a file being uploaded: skip it 
    4747                continue 
  • trunk/cherrypy/test/helper.py

    r320 r323  
    5656        if not port_is_free(): 
    5757            raise IOError("Port %s is in use; perhaps the previous server " 
    58                           "did not shut down properly." % port
     58                          "did not shut down properly." % PORT
    5959        t = threading.Thread(target=cpg.server.start, args=(False, serverClass)) 
    6060        t.start() 
  • trunk/cherrypy/tutorial/tut11_file_upload.py

    r319 r323  
    2323            myFile mime-type: %s 
    2424        </body></html> 
    25         """ % (len(myFile), 
    26                cpg.request.filenameMap['myFile']
    27                cpg.request.fileTypeMap['myFile']
     25        """ % (len(myFile.value), 
     26               myFile.filename
     27               myFile.type
    2828    upload.exposed = True 
    2929 

Hosted by WebFaction

Log in as guest/cpguest to create tickets