[FIX] bug in cache system that altered some arguments passed to cached function
lp bug: https://launchpad.net/bugs/413586 fixed bzr revid: christophe@tinyerp.com-20090814150506-04f3uficgdtd3uqu
This commit is contained in:
parent
d4d6e89b8e
commit
b34691c2f6
|
@ -599,9 +599,16 @@ class cache(object):
|
|||
"""
|
||||
|
||||
def to_tuple(d):
|
||||
i = d.items()
|
||||
i.sort(key=lambda (x,y): x)
|
||||
return tuple(i)
|
||||
pairs = d.items()
|
||||
pairs.sort(key=lambda (k,v): k)
|
||||
for i, (k, v) in enumerate(pairs):
|
||||
if isinstance(v, dict):
|
||||
pairs[i] = (k, to_tuple(v))
|
||||
if isinstance(v, (list, set)):
|
||||
pairs[i] = (k, tuple(v))
|
||||
elif not is_hashable(v):
|
||||
pairs[i] = (k, repr(v))
|
||||
return tuple(pairs)
|
||||
|
||||
if not self.multi:
|
||||
key = (('dbname', dbname),) + to_tuple(kwargs2)
|
||||
|
@ -618,12 +625,6 @@ class cache(object):
|
|||
kwargs2 = self.fun_default_values.copy()
|
||||
kwargs2.update(kwargs)
|
||||
kwargs2.update(dict(zip(self.fun_arg_names, args[self.skiparg-2:])))
|
||||
for k in kwargs2:
|
||||
if isinstance(kwargs2[k], (list, dict, set)):
|
||||
kwargs2[k] = tuple(kwargs2[k])
|
||||
elif not is_hashable(kwargs2[k]):
|
||||
kwargs2[k] = repr(kwargs2[k])
|
||||
|
||||
return kwargs2
|
||||
|
||||
def clear(self, dbname, *args, **kwargs):
|
||||
|
|
Loading…
Reference in New Issue