Commit a183a3a3 authored by Łukasz Nowak's avatar Łukasz Nowak

Add asJSON helper exporter.

parent ed276743
...@@ -26,8 +26,12 @@ ...@@ -26,8 +26,12 @@
############################################################################## ##############################################################################
import subprocess import subprocess
import json
def formatXml(self, xml): def formatXml(self, xml):
"""Simple way to have nicely formatted XML""" """Simple way to have nicely formatted XML"""
popen = subprocess.Popen(['xmllint', '--format', '--recover', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) popen = subprocess.Popen(['xmllint', '--format', '--recover', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
return popen.communicate(xml)[0] return popen.communicate(xml)[0]
def asJSON(self, o):
return json.dumps(o, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>asJSON</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ViFiBWeb</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>asJSON</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
321 322
\ No newline at end of file \ No newline at end of file
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