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:
parent
fc3230e5b5
commit
b880efba3e
2 changed files with 3 additions and 3 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue