Mercurial > libervia-backend
changeset 981:58a57ce5932a
core (XMLUI): _cleanValue method to avoid issues with DBus types (must be deleted in the future)
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 07 Apr 2014 16:22:35 +0200 (2014-04-07) |
parents | f0bba18835ef |
children | 0e80ee1fe9af |
files | src/tools/xml_tools.py |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/tools/xml_tools.py Mon Apr 07 16:22:35 2014 +0200 +++ b/src/tools/xml_tools.py Mon Apr 07 16:22:35 2014 +0200 @@ -151,12 +151,24 @@ 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 """