Mercurial > libervia-backend
diff src/tools/xml_tools.py @ 761:2f8d72226bc0
core (xml_tools): dataForm*2XML renamed to dataForm*2XMLUI and now return XMLUI instead of raw XML + submit_id is managed, and session_id is returned if present
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 24 Dec 2013 15:43:22 +0100 |
parents | 73a0077f80cc |
children | aed7d99276b8 |
line wrap: on
line diff
--- a/src/tools/xml_tools.py Tue Dec 24 15:19:18 2013 +0100 +++ b/src/tools/xml_tools.py Tue Dec 24 15:43:22 2013 +0100 @@ -26,10 +26,10 @@ """This library help manage XML used in SàT (parameters, registration, etc) """ -def dataForm2XML(form): +def dataForm2XMLUI(form, submit_id, session_id=None): """Take a data form (xep-0004, Wokkel's implementation) and convert it to a SàT xml""" - form_ui = XMLUI("form", "vertical") + form_ui = XMLUI("form", "vertical", submit_id=submit_id, session_id=session_id) if form.instructions: form_ui.addText('\n'.join(form.instructions), 'instructions') @@ -59,12 +59,12 @@ form_ui.addEmpty() form_ui.addElement(__field_type, field.var, field.value, [option.value for option in field.options]) - return form_ui.toXml() + return form_ui def dataFormResult2AdvancedList(form_ui, form_xml): """Take a raw data form (not parsed by XEP-0004) and convert it to an advanced list raw data form is used because Wokkel doesn't manage result items parsing yet - @param form_ui: the XMLUI where the AdvancedList will be added² + @param form_ui: the XMLUI where the AdvancedList will be added @param form_xml: domish.Element of the data form @return: AdvancedList element """ @@ -105,16 +105,16 @@ return form_ui.addAdvancedList(None, headers, items) -def dataFormResult2XML(form_xml): +def dataFormResult2XMLUI(form_xml, session_id=None): """Take a raw data form (not parsed by XEP-0004) and convert it to a SàT XMLUI raw data form is used because Wokkel doesn't manage result items parsing yet @param form_xml: domish.Element of the data form @return: XMLUI interface """ - form_ui = XMLUI("window", "vertical") + form_ui = XMLUI("window", "vertical", session_id=session_id) dataFormResult2AdvancedList(form_ui, form_xml) - return form_ui.toXml() + return form_ui def tupleList2dataForm(values): """convert a list of tuples (name,value) to a wokkel submit data form"""