mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-23 18:04:34 +00:00
Add (de-)serialization of set objects in sessions
This commit is contained in:
@@ -19,6 +19,8 @@ class SessionEncoder(json.JSONEncoder):
|
|||||||
return {"_type": "datetime_isoformat", "value": obj.isoformat()}
|
return {"_type": "datetime_isoformat", "value": obj.isoformat()}
|
||||||
elif isinstance(obj, date):
|
elif isinstance(obj, date):
|
||||||
return {"_type": "date_isoformat", "value": obj.isoformat()}
|
return {"_type": "date_isoformat", "value": obj.isoformat()}
|
||||||
|
elif isinstance(obj, set):
|
||||||
|
return {"_type": "set", "value": tuple(obj)}
|
||||||
return json.JSONEncoder.default(self, obj)
|
return json.JSONEncoder.default(self, obj)
|
||||||
|
|
||||||
|
|
||||||
@@ -36,4 +38,6 @@ class SessionDecoder(json.JSONDecoder):
|
|||||||
return dateutil.parser.parse(obj["value"])
|
return dateutil.parser.parse(obj["value"])
|
||||||
elif type_ == "date_isoformat":
|
elif type_ == "date_isoformat":
|
||||||
return dateutil.parser.parse(obj["value"]).date()
|
return dateutil.parser.parse(obj["value"]).date()
|
||||||
|
elif type_ == "set":
|
||||||
|
return set(obj["value"])
|
||||||
return obj
|
return obj
|
||||||
|
|||||||
Reference in New Issue
Block a user