Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
ea60ed13
Commit
ea60ed13
authored
Sep 28, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Add _asDict function to get the dict representation of objects
parent
9a28cb13
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
product/ERP5Type/mixin/json_representable.py
product/ERP5Type/mixin/json_representable.py
+15
-2
No files found.
product/ERP5Type/mixin/json_representable.py
View file @
ea60ed13
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment