From f3f582eaa0a37bcc47b3abaf643baa1c12508927 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 21 Oct 2011 09:22:40 +0200 Subject: [PATCH] [IMP] add debug keys to nonliteral domains and contexts, simplify keyscheck for validity (and make it look like python code) bzr revid: xmo@openerp.com-20111021072240-82wly4vbkmmqn15z --- addons/web/common/nonliterals.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/web/common/nonliterals.py b/addons/web/common/nonliterals.py index 42dbe9cfd4f..f6e81894a4c 100644 --- a/addons/web/common/nonliterals.py +++ b/addons/web/common/nonliterals.py @@ -21,12 +21,14 @@ class NonLiteralEncoder(simplejson.encoder.JSONEncoder): if isinstance(object, Domain): return { '__ref': 'domain', - '__id': object.key + '__id': object.key, + '__debug': object.get_domain_string() } elif isinstance(object, Context): return { '__ref': 'context', - '__id': object.key + '__id': object.key, + '__debug': object.get_context_string() } elif isinstance(object, CompoundDomain): return { @@ -42,7 +44,7 @@ class NonLiteralEncoder(simplejson.encoder.JSONEncoder): } raise TypeError('Could not encode unknown non-literal %s' % object) -_ALLOWED_KEYS = frozenset(['__ref', "__id", '__domains', +_ALLOWED_KEYS = frozenset(['__ref', "__id", '__domains', '__debug', '__contexts', '__eval_context', 'own_values']) def non_literal_decoder(dct): @@ -53,8 +55,8 @@ def non_literal_decoder(dct): ``own_values`` dict key. """ if '__ref' in dct: - for x in dct.keys(): - if not x in _ALLOWED_KEYS: + for x in dct: + if x not in _ALLOWED_KEYS: raise ValueError("'%s' key not allowed in non literal domain/context" % x) if dct['__ref'] == 'domain': domain = Domain(None, key=dct['__id'])