durusmail: quixote-users: StaticDirectory serving index files again
StaticDirectory serving index files again
StaticDirectory serving index files again
Shalabh Chaturvedi
2004-10-01
Neil Schemenauer wrote:
> On Tue, Sep 28, 2004 at 01:26:06PM -0700, Shalabh Chaturvedi wrote:
>
>>The patch attached adds a feature to util.StaticDirectory enabling
>>it to return an index page (such as index.html) instead of
>>directory listing.  A parameter in __init__() specifies a tuple of
>>filenames that are looked up in the directory
>
>
> Should be a list not a tuple.

Ok. Should I send out an updated patch?

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?

Thanks,
Shalabh


reply