core (XMLUI): _cleanValue method to avoid issues with DBus types (must be deleted in the future)

This commit is contained in:
Goffi 2014-04-07 16:22:35 +02:00
commit c497e19b25

View file

@ -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 """