SVN: r22728 - trunk/quixote
Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Fri, 10 Oct 2003 10:02:47 -0400
| Newsgroups | gmane.comp.web.quixote.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: nascheme
Date: 2003-10-10 10:02:46 -0400 (Fri, 10 Oct 2003)
New Revision: 22728
Modified:
trunk/quixote/util.py
Log:
Allow StaticFile class to be overridden. Also, make it easier to
subclass StaticDirectory.
Modified: trunk/quixote/util.py
===================================================================
--- trunk/quixote/util.py 2003-10-10 13:36:05 UTC (rev 22727)
+++ trunk/quixote/util.py 2003-10-10 14:02:46 UTC (rev 22728)
@@ -152,10 +152,13 @@
_q_exports = []
+ FILE_CLASS = StaticFile
+
def __init__(self, path, use_cache=0, list_directory=0, follow_symlinks=0,
- cache_time=None):
- """StaticDirectory(path:string, use_cache:bool,
- list_directory:bool, follow_symlinks:bool)
+ cache_time=None, file_class=None):
+ """StaticDirectory(path:string, use_cache:bool, list_directory:bool,
+ follow_symlinks:bool, cache_time:int,
+ file_class=None)
Initialize instance with the absolute path to the file.
If 'use_cache' is true, StaticFile instances will be cached in memory.
@@ -176,6 +179,10 @@
self.list_directory = list_directory
self.follow_symlinks = follow_symlinks
self.cache_time = cache_time
+ if file_class is not None:
+ self.file_class = file_class
+ else:
+ self.file_class = self.FILE_CLASS
def _q_index(self, request):
"""
@@ -226,11 +233,13 @@
item_filepath = os.path.join(self.path, dest)
if os.path.isdir(item_filepath):
- item = StaticDirectory(item_filepath, self.use_cache,
- self.list_directory, self.follow_symlinks, self.cache_time)
+ item = self.__class__(item_filepath, self.use_cache,
+ self.list_directory,
+ self.follow_symlinks, self.cache_time,
+ self.file_class)
elif os.path.isfile(item_filepath):
- item = StaticFile(item_filepath, self.follow_symlinks,
- cache_time=self.cache_time)
+ item = self.file_class(item_filepath, self.follow_symlinks,
+ cache_time=self.cache_time)
else:
raise errors.TraversalError
if self.use_cache: