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

Changeset 1401

Show
Ignore:
Timestamp:
10/19/06 18:31:40
Author:
fumanchu
Message:

Inline isdir to save a call to os.stat.

Files:

Legend:

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

    r1318 r1401  
    77import os 
    88import re 
     9import stat 
    910import time 
    1011import urllib 
     
    3738     
    3839    try: 
    39         stat = os.stat(path) 
     40        st = os.stat(path) 
    4041    except OSError: 
    4142        raise cherrypy.NotFound() 
    4243     
    43     if os.path.isdir(path): 
     44    # Check if path is a directory. 
     45    if stat.S_ISDIR(st.st_mode): 
    4446        # Let the caller deal with it as they like. 
    4547        raise cherrypy.NotFound() 
     
    4749    # Set the Last-Modified response header, so that 
    4850    # modified-since validation code can work. 
    49     response.headers['Last-Modified'] = http.HTTPDate(stat.st_mtime) 
     51    response.headers['Last-Modified'] = http.HTTPDate(st.st_mtime) 
    5052    cptools.validate_since() 
    5153     
     
    6769    # Set Content-Length and use an iterable (file object) 
    6870    #   this way CP won't load the whole file in memory 
    69     c_len = stat.st_size 
     71    c_len = st.st_size 
    7072    bodyfile = open(path, 'rb') 
    7173     

Hosted by WebFaction

Log in as guest/cpguest to create tickets