Commit 040b7b21 authored by Vincent Pelletier's avatar Vincent Pelletier

Prevent cache system from hiding KeyErrors in invoked methods. It must only...

Prevent cache system from hiding KeyErrors in invoked methods. It must only handle the cas of missing cache factory.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23136 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 05027171
...@@ -189,9 +189,7 @@ class CachingMethod: ...@@ -189,9 +189,7 @@ class CachingMethod:
## which is faster than checking for keys ## which is faster than checking for keys
# It is very important to take the factories dictionnary # It is very important to take the factories dictionnary
# on CachingMethod instead of self, we want a global variable # on CachingMethod instead of self, we want a global variable
value = CachingMethod.factories[self.cache_factory]( cache_factory = CachingMethod.factories[self.cache_factory]
self.callable_object, cache_id, scope, self.cache_duration,
*args, **kwd)
except KeyError: except KeyError:
global is_cache_ready global is_cache_ready
if is_cache_ready: if is_cache_ready:
...@@ -200,6 +198,10 @@ class CachingMethod: ...@@ -200,6 +198,10 @@ class CachingMethod:
"Factory %s not found, method %s executed without cache" % ( "Factory %s not found, method %s executed without cache" % (
self.cache_factory, self.callable_object)) self.cache_factory, self.callable_object))
value = self.callable_object(*args, **kwd) value = self.callable_object(*args, **kwd)
else:
value = cache_factory(
self.callable_object, cache_id, scope, self.cache_duration,
*args, **kwd)
return value return value
def delete(self, id, cache_factory=DEFAULT_CACHE_FACTORY, scope=DEFAULT_CACHE_SCOPE): def delete(self, id, cache_factory=DEFAULT_CACHE_FACTORY, scope=DEFAULT_CACHE_SCOPE):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment