Commit ea60ed13 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Add _asDict function to get the dict representation of objects

parent 9a28cb13
......@@ -57,14 +57,27 @@ class JSONRepresentableMixin:
respresentation and then use xmltodict to convert it to dict and JSON
format finally
"""
dict_value = self._asDict()
# Convert the XML to json representation
return json.dumps(dict_value)
security.declareProtected(Permissions.AccessContentsInformation, 'asDict')
def _asDict(self):
"""
Gets the dict representation of the object
"""
# Use OFS exportXML to first export to xml
f = StringIO()
XMLExportImport.exportXML(self._p_jar, self._p_oid, f)
# Get the value of exported XML
xml_value = f.getvalue()
return xmltodict.parse(xml_value)
# Convert the XML to json representation
return json.dumps(xmltodict.parse(xml_value))
def fromJSON(self):
"""
Updates an object, based on a JSON representation
"""
pass
InitializeClass(JSONRepresentableMixin)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment