[FIX] context recursion: create the recursion (context['context'] = context) at the latest possible moment, otherwise due to shallow dict copies not preserving recursion nested contexts don't contain all values of the toplevel context
setup recursion into OpenERPSession.evaluation_context, instead of doing this wherever (e.g. OpenERPSession.eval_context) bzr revid: xmo@openerp.com-20110715092451-yz7f272uix1zqb8e
This commit is contained in:
parent
f40328b46a
commit
2f8d2412ac
|
@ -172,9 +172,8 @@ class Context(BaseContext):
|
|||
ctx = self.session.evaluation_context(context)
|
||||
if self.own:
|
||||
ctx.update(self.own)
|
||||
return eval(self.get_context_string(),
|
||||
SuperDict(ctx))
|
||||
|
||||
return eval(self.get_context_string(), SuperDict(ctx))
|
||||
|
||||
class SuperDict(dict):
|
||||
def __getattr__(self, name):
|
||||
try:
|
||||
|
@ -182,7 +181,7 @@ class SuperDict(dict):
|
|||
except KeyError:
|
||||
raise AttributeError(name)
|
||||
def __getitem__(self, key):
|
||||
tmp = super(type(self), self).__getitem__(key)
|
||||
tmp = super(SuperDict, self).__getitem__(key)
|
||||
if isinstance(tmp, dict):
|
||||
return SuperDict(tmp)
|
||||
return tmp
|
||||
|
@ -208,8 +207,7 @@ class CompoundDomain(BaseDomain):
|
|||
|
||||
ctx = dict(context or {})
|
||||
ctx.update(self.get_eval_context() or {})
|
||||
ctx['context'] = ctx
|
||||
|
||||
|
||||
domain.session = self.session
|
||||
final_domain.extend(domain.evaluate(ctx))
|
||||
return final_domain
|
||||
|
@ -247,8 +245,7 @@ class CompoundContext(BaseContext):
|
|||
continue
|
||||
|
||||
ctx.update(final_context)
|
||||
ctx["context"] = ctx
|
||||
|
||||
|
||||
context_to_eval.session = self.session
|
||||
final_context.update(context_to_eval.evaluate(ctx))
|
||||
return final_context
|
||||
|
|
|
@ -174,10 +174,10 @@ class OpenERPSession(object):
|
|||
:returns: the augmented context
|
||||
:rtype: dict
|
||||
"""
|
||||
d = {}
|
||||
d.update(self.base_eval_context)
|
||||
d = dict(self.base_eval_context)
|
||||
if context:
|
||||
d.update(context)
|
||||
d['context'] = d
|
||||
return d
|
||||
|
||||
def eval_context(self, context_to_eval, context=None):
|
||||
|
@ -197,7 +197,6 @@ class OpenERPSession(object):
|
|||
ctx = dict(
|
||||
self.base_eval_context,
|
||||
**(context or {}))
|
||||
ctx['context'] = ctx
|
||||
|
||||
# adding the context of the session to send to the openerp server
|
||||
ccontext = nonliterals.CompoundContext(self.context, context_to_eval or {})
|
||||
|
@ -222,12 +221,9 @@ class OpenERPSession(object):
|
|||
if isinstance(domain, list):
|
||||
return domain
|
||||
|
||||
ctx = dict(context or {})
|
||||
ctx['context'] = ctx
|
||||
|
||||
cdomain = nonliterals.CompoundDomain(domain)
|
||||
cdomain.session = self
|
||||
return cdomain.evaluate(ctx)
|
||||
return cdomain.evaluate(context or {})
|
||||
|
||||
#----------------------------------------------------------
|
||||
# OpenERP Web RequestHandler
|
||||
|
|
Loading…
Reference in New Issue