--- util.py.ims 2003-05-28 12:39:05.000000000 -0500 +++ util.py.expires 2003-05-28 12:37:29.000000000 -0500 @@ -68,7 +68,7 @@ """ def __init__(self, path, follow_symlinks=0, - mime_type=None, encoding=None): + mime_type=None, encoding=None, cache_time=3600): """StaticFile(path:string, follow_symlinks:bool) Initialize instance with the absolute path to the file. If @@ -92,6 +92,7 @@ strict=0) self.mime_type = mime_type or guess_mime or 'text/plain' self.encoding = encoding or guess_enc or None + self.cache_time = cache_time def __call__(self, request): last_mod = os.stat(self.path).st_mtime @@ -116,6 +117,11 @@ last_modified = formatdate(last_mod) request.response.set_header('Last-Modified', last_modified) + # set the cache value (so the response object can set + # the "Expires:" header correctly) + if self.cache_time != None: + request.response.cache = self.cache_time + return contents @@ -127,7 +133,7 @@ _q_exports = [] - def __init__(self, path, use_cache=0, list_directory=0, follow_symlinks=0): + def __init__(self, path, use_cache=0, list_directory=0, follow_symlinks=0, cache_time=3600): """StaticDirectory(path:string, use_cache:bool, list_directory:bool, follow_symlinks:bool) @@ -146,6 +152,7 @@ self.cache = {} self.list_directory = list_directory self.follow_symlinks = follow_symlinks + self.cache_time = cache_time def _q_index(self, request): """ @@ -199,7 +206,7 @@ item = StaticDirectory(item_filepath, self.use_cache, self.list_directory, self.follow_symlinks) elif os.path.isfile(item_filepath): - item = StaticFile(item_filepath, self.follow_symlinks) + item = StaticFile(item_filepath, self.follow_symlinks, cache_time=self.cache_time) else: raise errors.TraversalError if self.use_cache: