Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #721 (defect)

Opened 1 year ago

Last modified 9 months ago

bug in tools.caching

Status: closed (fixed)

Reported by: guest Assigned to: rdelon
Priority: normal Milestone: 3.1
Component: CherryPy code Keywords:
Cc:

in caching.py

class MemoryCache:
    ...
    def get(self):
        """Return the object if in the cache, else None."""
        self.tot_gets += 1
        cache_item = self.cache.get(self.key, None)
        if cache_item:
            self.tot_hist += 1
            return cache_item
        else:
            return None

should be

        if cache_item:
            self.tot_hist += 1
            return copy.deepcopy(cache_item)

or the cached content will be modified by something like 304 status, it's call by reference


and here is another

def get(invalid_methods=("POST", "PUT", "DELETE"), cache_class=MemoryCache):
    ...
    if c:
        ...
        try:
            # Note that validate_since depends on a Last-Modified header;
            # this was put into the cached copy, and should have been
            # resurrected just above (response.headers = cache_data[1]).
            cptools.validate_since()
        except cherrypy.HTTPError, x:
            if x.status == 304:
                cherrypy._cache.tot_non_modified += 1
            raise

currently validate_since() raise HTTPRedirect([], 304), HTTPRedirect is not a subclass of HTTPError, so it won't enter this exception with 304

        except cherrypy.HTTPRedirect, x:

Change History

10/26/07 23:10:59: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to 3.1.

Fixed in [1771].

Hosted by WebFaction

Log in as guest/cpguest to create tickets