From c497e19b250f99577a13ae43300d7d2ab24d63a4 Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 7 Apr 2014 16:22:35 +0200 Subject: [PATCH] core (XMLUI): _cleanValue method to avoid issues with DBus types (must be deleted in the future) --- src/tools/xml_tools.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/tools/xml_tools.py b/src/tools/xml_tools.py index 2751d4ad..1da5bc89 100644 --- a/src/tools/xml_tools.py +++ b/src/tools/xml_tools.py @@ -151,12 +151,24 @@ def dataFormResult2XMLUI(form_xml, session_id=None): dataFormResult2AdvancedList(xmlui, form_xml) return xmlui +def _cleanValue(value): + """Workaround method to avoid DBus types with D-Bus bridge + + @param value: value to clean + @return: value in a non DBus type (only clean string yet) + """ + # XXX: must be removed when DBus types will no cause problems anymore + # FIXME: should be cleaned inside D-Bus bridge itself + if isinstance(value, basestring): + return unicode(value) + return value + def XMLUIResult2DataFormResult(xmlui_data): """ Extract form data from a XMLUI return @xmlui_data: data returned by frontends for XMLUI form @return: dict of data usable by Wokkel's dataform """ - return {key[len(SAT_FORM_PREFIX):]: value for key, value in xmlui_data.iteritems() if key.startswith(SAT_FORM_PREFIX)} + return {key[len(SAT_FORM_PREFIX):]: _cleanValue(value) for key, value in xmlui_data.iteritems() if key.startswith(SAT_FORM_PREFIX)} def formEscape(name): """ Return escaped name for forms """