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

Changeset 1242

Show
Ignore:
Timestamp:
08/12/06 11:16:54
Author:
fumanchu
Message:

Fix for #547 (serve_file still uses contentType instead of content_type). Thanks, michele!

Files:

Legend:

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

    r1224 r1242  
    1414 
    1515 
    16 def serve_file(path, contentType=None, disposition=None, name=None): 
     16def serve_file(path, content_type=None, disposition=None, name=None): 
    1717    """Set status, headers, and body in order to serve the given file. 
    1818     
    19     The Content-Type header will be set to the contentType arg, if provided. 
     19    The Content-Type header will be set to the content_ype arg, if provided. 
    2020    If not provided, the Content-Type will be guessed by its extension. 
    2121     
     
    5252    cptools.validate_since() 
    5353     
    54     if contentType is None: 
     54    if content_type is None: 
    5555        # Set content-type based on filename extension 
    5656        ext = "" 
     
    5858        if i != -1: 
    5959            ext = path[i:].lower() 
    60         contentType = mimetypes.types_map.get(ext, "text/plain") 
    61     response.headers['Content-Type'] = contentType 
     60        content_type = mimetypes.types_map.get(ext, "text/plain") 
     61    response.headers['Content-Type'] = content_type 
    6262     
    6363    if disposition is not None: 
     
    102102                    for start, stop in r: 
    103103                        yield "--" + boundary 
    104                         yield "\nContent-type: %s" % contentType 
     104                        yield "\nContent-type: %s" % content_type 
    105105                        yield ("\nContent-range: bytes %s-%s/%s\n\n" 
    106106                               % (start, stop - 1, c_len)) 
     
    133133            r, ext = os.path.splitext(filename) 
    134134            content_type = content_types.get(ext[1:], None) 
    135         serve_file(filename, contentType=content_type) 
     135        serve_file(filename, content_type=content_type) 
    136136        return True 
    137137    except cherrypy.NotFound: 
  • trunk/cherrypy/tutorial/tut09_files.py

    r1219 r1242  
    2828arguments: 
    2929 
    30 serve_file(path, contentType=None, disposition=None, name=None) 
     30serve_file(path, content_type=None, disposition=None, name=None) 
    3131 
    3232Set "name" to the filename that you expect clients to use when they save 
    3333your file. Note that the "name" argument is ignored if you don't also 
    3434provide a "disposition" (usually "attachement"). You can manually set 
    35 "contentType", but be aware that if you also use the encoding tool, it 
     35"content_type", but be aware that if you also use the encoding tool, it 
    3636may choke if the file extension is not recognized as belonging to a known 
    37 Content-Type. Setting the contentType to "application/x-download" works 
     37Content-Type. Setting the content_type to "application/x-download" works 
    3838in most cases, and should prompt the user with an Open/Save dialog in 
    3939popular browsers. 

Hosted by WebFaction

Log in as guest/cpguest to create tickets