Oleg Broytmann wrote: > On Fri, Oct 01, 2004 at 10:55:00AM -0700, Shalabh Chaturvedi wrote: > >>Also, I thought of subclassing StaticDirectory but the only reason I >>couldn't is because the following code in _q_lookup(): >> >> item = self.__class__(item_filepath, self.use_cache, >> self.list_directory, >> self.follow_symlinks, self.cache_time, >> self.file_class) >> >>Here a new directory object is created using the parameters of the self >>object. For a subclass, the parameters of __init__() are different, and >>this line needs to be changed to pass the new parameters. If we instead >>implement this as: >> >> item = self.new_directory(item_filepath) >> >>and: >> >> def new_directory(self, item_filepath): >> return self.__class__(item_filepath, >> self.use_cache, >> self.list_directory, >> self.follow_symlinks, self.cache_time, >> self.file_class) >> >>then not only I could implement my requirement as a subclass, but others >>too might add what they need by subclassing. Do you think this is better? > > > +0.5 > > Oleg. At least this one got some support :) Attached is a patch for util.py. It's much simpler than the earlier patch. Shalabh
--- down/quixote-1/Quixote-1.0/util.py Fri Oct 10 07:02:46 2003 +++ /usr/local/lib/python2.3/site-packages/quixote/util.py Sun Oct 3 11:48:19 2004 @@ -234,8 +234,5 @@ if os.path.isdir(item_filepath): - item = self.__class__(item_filepath, self.use_cache, - self.list_directory, - self.follow_symlinks, self.cache_time, - self.file_class) + item = self.new_directory(item_filepath) elif os.path.isfile(item_filepath): item = self.file_class(item_filepath, self.follow_symlinks, @@ -246,4 +243,13 @@ self.cache[name] = item return item + + def new_directory(self, item_filepath): + """ + Return a new directory object using parameters of this object + """ + return self.__class__(item_filepath, self.use_cache, + self.list_directory, + self.follow_symlinks, self.cache_time, + self.file_class)