add utility for caching values in the request

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3794 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2010-03-30 13:37:23 +00:00
parent fc3230e5b5
commit b880efba3e
2 changed files with 3 additions and 3 deletions

View file

@ -31,7 +31,7 @@ def caching(self, method, id):
item = annot.setdefault('cybertools.zutil.rcache', {}) item = annot.setdefault('cybertools.zutil.rcache', {})
value = item.get(id, INVALID) value = item.get(id, INVALID)
if value is INVALID: if value is INVALID:
value = method() value = method(self)
item[id] = value item[id] = value
return value return value

View file

@ -12,12 +12,12 @@ $Id$
... self.request = request ... self.request = request
... ...
... @rcache ... @rcache
... def calculate(): ... def calculate(self):
... print 'calculating' ... print 'calculating'
... return 42 ... return 42
... ...
... @rcacheproperty ... @rcacheproperty
... def value(): ... def value(self):
... print 'calculating' ... print 'calculating'
... return 43 ... return 43