comparison src/tools/xml_tools.py @ 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
parents d2e612a45e76
children 301b342c697a
comparison
equal deleted inserted replaced
980:f0bba18835ef 981:58a57ce5932a
149 149
150 xmlui = XMLUI("window", "vertical", session_id=session_id) 150 xmlui = XMLUI("window", "vertical", session_id=session_id)
151 dataFormResult2AdvancedList(xmlui, form_xml) 151 dataFormResult2AdvancedList(xmlui, form_xml)
152 return xmlui 152 return xmlui
153 153
154 def _cleanValue(value):
155 """Workaround method to avoid DBus types with D-Bus bridge
156
157 @param value: value to clean
158 @return: value in a non DBus type (only clean string yet)
159 """
160 # XXX: must be removed when DBus types will no cause problems anymore
161 # FIXME: should be cleaned inside D-Bus bridge itself
162 if isinstance(value, basestring):
163 return unicode(value)
164 return value
165
154 def XMLUIResult2DataFormResult(xmlui_data): 166 def XMLUIResult2DataFormResult(xmlui_data):
155 """ Extract form data from a XMLUI return 167 """ Extract form data from a XMLUI return
156 @xmlui_data: data returned by frontends for XMLUI form 168 @xmlui_data: data returned by frontends for XMLUI form
157 @return: dict of data usable by Wokkel's dataform 169 @return: dict of data usable by Wokkel's dataform
158 """ 170 """
159 return {key[len(SAT_FORM_PREFIX):]: value for key, value in xmlui_data.iteritems() if key.startswith(SAT_FORM_PREFIX)} 171 return {key[len(SAT_FORM_PREFIX):]: _cleanValue(value) for key, value in xmlui_data.iteritems() if key.startswith(SAT_FORM_PREFIX)}
160 172
161 def formEscape(name): 173 def formEscape(name):
162 """ Return escaped name for forms """ 174 """ Return escaped name for forms """
163 return u"%s%s" % (SAT_FORM_PREFIX, name) 175 return u"%s%s" % (SAT_FORM_PREFIX, name)
164 176