durusmail: quixote-users: Augmenting StaticFile to use "Expires:"
Augmenting StaticFile to use "Expires:"
2003-05-31
2003-05-31
2003-06-02
Jason Sibre (3 parts)
Re: Augmenting StaticFile to use "Expires:"
2003-06-21
2003-06-21
2003-06-23
Re: Augmenting StaticFile to use "Expires:"
2003-07-15
Augmenting StaticFile to use "Expires:"
Jason Sibre
2003-05-31
Harald,
Good point about the default behavior.  I originally set it up such that the
default would be both convenient and acceptable for most purposes, but I
think your point is valid that preserving consistent behavior for those who
simply dump in the new util.py without being aware of the changes is more
important.

Thanks for spotting that bug in the directory within directory situation...
I didn't have any sub-directories set up when I was testing (and still
don't) so I hadn't even thought about that scenario.

I'll revisit that file, and send out a couple of new diffs as soon as I've
made the fixes.

Thanks for the feedback,

Jason Sibre

-----Original Message-----
From: Massa, Harald [mailto:harald.massa@suedvers.de]
Sent: Saturday, May 31, 2003 2:34 PM
To: 'Jason Sibre'; quixote-users@mems-exchange.org
Cc: 'Graham Fawcett'
Subject: AW: [Quixote-users] Augmenting StaticFile to use "Expires:"


Jason,
very nice patch, really improving Cache-Performance!
I have to additions:
first: I would like the default to be -1, no Caching. So when swapping in
your util.py, working code does not get broken.
Second:
within
def _q_lookup(self, request, name):
there are two distinctions: files and directories. In your patch cache_time
is only passed on to files, not to directories.
So I suggest:
 def _q_lookup(self, request, name):
        """
        Get a file from the filesystem directory and return the StaticFile
        or StaticDirectory wrapper of it; use caching if that is in use.
        """
        if name in ('.', '..'):
            raise errors.TraversalError(private_msg="Attempt to use '.',
'..'")
        if self.cache.has_key(name):
            # Get item from cache
            item = self.cache[name]
        else:
            # Get item from filesystem; cache it if caching is in use.
            item_filepath = os.path.join(self.path, name)
            while os.path.islink(item_filepath):
                if not self.follow_symlinks:
                    raise errors.TraversalError
                else:
                    dest = os.readlink(item_filepath)
                    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,cache_time=self.cache_time) # !!! also propagate
cache-time to subdirectories
            elif os.path.isfile(item_filepath):
                item = StaticFile(item_filepath, self.follow_symlinks,
cache_time=self.cache_time)
            else:
                raise errors.TraversalError
            if self.use_cache:
                self.cache[name] = item
        if isinstance(item, StaticDirectory):
            return item
        else:
            return item(request)



Thank you very much for sharing this extension,
best wishes, Harald


reply