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

This commit is contained in:
Goffi 2013-12-24 15:43:22 +01:00
commit 4d15d4a4eb

View file

@ -26,10 +26,10 @@ from sat.core import exceptions
"""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 @@ def dataForm2XML(form):
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 @@ def dataFormResult2AdvancedList(form_ui, form_xml):
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"""