Commit 10c8b5b3 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

slapos_slap_tool: cast Dict to XML string available as a python script

parent 9c110013
from lxml import etree
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager, newSecurityManager
......@@ -56,3 +58,12 @@ def reindexPartition(item):
def Instance_reindexComputePartition(state_change):
item = state_change['object']
reindexPartition(item)
def castDictToXMLString(dict_kw):
instance = etree.Element('instance')
for _id, _value in dict_kw.iteritems():
# cast everything to string
etree.SubElement(instance, "parameter",
attrib={'id':_id}).text = str(_value)
return etree.tostring(instance, pretty_print=True,
xml_declaration=True, encoding='utf-8')
<?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>castDictToXMLString</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSSlapTool</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_castDictToXMLString</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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