Skip to content

Commit

Permalink
- Avoid a lot of warnings when we try to RAM cache
Browse files Browse the repository at this point in the history
  in a context we don't have a Request.
  [thomasdesvenain]
  • Loading branch information
tdesvenain committed Dec 20, 2013
1 parent 517e2f1 commit e4b7070
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -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)
-------------------
Expand Down
7 changes: 7 additions & 0 deletions src/Products/StandardCacheManagers/RAMCacheManager.py
Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit e4b7070

Please sign in to comment.