diff --git a/CHANGES.txt b/CHANGES.txt index 65466fb..f5d2dbb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,9 @@ Changelog 2.13.1 (unreleased) ------------------- +- Avoid a lot of warnings when we try to RAM cache + in a context we don't have a Request. + [thomasdesvenain] 2.13.0 (2010-07-11) ------------------- diff --git a/src/Products/StandardCacheManagers/RAMCacheManager.py b/src/Products/StandardCacheManagers/RAMCacheManager.py index d64975e..14b0a04 100644 --- a/src/Products/StandardCacheManagers/RAMCacheManager.py +++ b/src/Products/StandardCacheManagers/RAMCacheManager.py @@ -290,10 +290,14 @@ def ZCache_get(self, ob, view_name='', keywords=None, ''' Gets a cache entry or returns default. ''' + if not hasattr(ob, 'REQUEST'): + return default + oc = self.getObjectCacheEntries(ob) if oc is None: return default lastmod = ob.ZCacheable_getModTime(mtime_func) + index = oc.aggregateIndex(view_name, ob.REQUEST, self.request_vars, keywords) entry = oc.getEntry(lastmod, index) @@ -316,6 +320,9 @@ def ZCache_set(self, ob, data, view_name='', keywords=None, ''' Sets a cache entry. ''' + if not hasattr(ob, 'REQUEST'): + return + now = time.time() if self.next_cleanup <= now: self.cleanup()