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-06-02
Ok,
I think this cleans things up nicely.  cache_time now defaults to None, and
unless I did something silly, this will produce identical behavior (with
regard to the Expires header) to an un-patched util.py.  I also fixed that
oversight about directories within directories (Thanks again for pointing
that out!)

As before, I have two patches to submit, one for util.py files that are
'stock' 0.6 release versions, which include both Graham's IMS support and my
Expires support, and another that will patch a util.py that has already been
patched for IMS support to include Expires support.

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