diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-12-03 13:23:12 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-12-03 13:23:12 +0100 |
| commit | f9670e67a24e4e6ce1090ffa8682fffa94e35dd1 (patch) | |
| tree | bf9a327d0663140be823c9521aa462f7eff084b5 /addons/web/static/lib | |
| parent | 54ea7670d36d84d47d52ede3f1d1a1c847141bc5 (diff) | |
[FIX] rollback default conversion of js Object to py.object (not py.dict) and add default toJSON to all py.object
* Accesses in contexts & domains are object derefs, so using dicts was
dumb
* But objects still need to round-trip through in case of e.g. o2m
commands in contexts, so py.object needs a toJSON (or a special
object kind needs to be added, specifically for round-tripping
objects through)
bzr revid: xmo@openerp.com-20121203122312-gc499mujf4l0nuz7
Diffstat (limited to 'addons/web/static/lib')
| -rw-r--r-- | addons/web/static/lib/py.js/lib/py.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/addons/web/static/lib/py.js/lib/py.js b/addons/web/static/lib/py.js/lib/py.js index f36cfd665b3..4ef92b40112 100644 --- a/addons/web/static/lib/py.js/lib/py.js +++ b/addons/web/static/lib/py.js/lib/py.js @@ -393,7 +393,13 @@ var py = {}; switch(val.constructor) { case Object: - return py.dict.fromJSON(val); + var out = py.PY_call(py.object); + for(var k in val) { + if (val.hasOwnProperty(k)) { + out[k] = val[k]; + } + } + return out; case Array: return py.list.fromJSON(val); } @@ -756,7 +762,14 @@ var py = {}; // Conversion toJSON: function () { - throw new Error(this.constructor.name + ' can not be converted to JSON'); + var out = {}; + for(var k in this) { + if (this.hasOwnProperty(k) && !/^__/.test(k)) { + var val = this[k]; + out[k] = val.toJSON ? val.toJSON() : val; + } + } + return out; } }); var NoneType = py.type('NoneType', null, { |
