[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
This commit is contained in:
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user