Commit 54a448f6 authored by Jérome Perrin's avatar Jérome Perrin

ERP5Form,ERP5OOo: drop dependency on PyXML

serialize as json instead of using xml.marshal.generic which was
provided by PyXML
parent 054c09b3
......@@ -28,6 +28,8 @@
##############################################################################
from __future__ import absolute_import
import json
import lxml.etree
from ZTUtils import make_query
from Products.Formulator import Widget
from Products.Formulator import Widget, Validator
......@@ -430,10 +432,9 @@ class OOoChartWidget(Widget.Widget):
REQUEST.set('render_prefix', render_prefix)
#needed to update REQUEST
argument_dict = self.getArgumentDict(field, REQUEST)
from xml.marshal.generic import dumps
dump_args = dumps(argument_dict)
#remove xml declaration (first processing node)
dump_args = dump_args[dump_args.index('?>')+2:]
marshal = lxml.etree.Element('marshal')
marshal.set('argument-dict-json', json.dumps(argument_dict))
dump_args = lxml.etree.tostring(marshal)
content = '''<office:include path="%s/ERP5Site_buildChart"
xlink:type="simple" xlink:actuate="onLoad"
xlink:show="embed">%s</office:include>
......
......@@ -29,6 +29,7 @@
from __future__ import absolute_import
from six import string_types as basestring
import json
from mimetypes import guess_extension
from OFS.Image import File
from Products.CMFCore.FSPageTemplate import FSPageTemplate
......@@ -425,9 +426,7 @@ class OOoTemplate(ZopePageTemplate):
for office_include in xml_doc.xpath('//office:include', namespaces=xml_doc.nsmap):
marshal_list = office_include.xpath('./marshal')
if marshal_list:
from xml.marshal.generic import loads
arg_dict = loads(etree.tostring(marshal_list[0], encoding='utf-8',
xml_declaration=True, pretty_print=False))
arg_dict = json.loads(marshal_list[0].get('argument-dict-json'))
extra_context.update(arg_dict)
request.other.update(arg_dict)
path = office_include.attrib['path']
......
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