core (XMLUI): data form result now manage generic data set
This commit is contained in:
parent
e18adb373d
commit
4bbf1e2be6
1 changed files with 23 additions and 12 deletions
|
|
@ -75,15 +75,13 @@ def _dataFormField2XMLUIData(field):
|
|||
|
||||
return widget_type, widget_args, widget_kwargs
|
||||
|
||||
def dataForm2Widgets(form_ui, form):
|
||||
"""Complete an existing XMLUI with widget converted frot XEP-0004 data forms
|
||||
|
||||
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
|
||||
@param submit_id: callback id to call when submitting form
|
||||
@param session_id: id to return with the data
|
||||
|
||||
@param form_ui: XMLUI instance
|
||||
@param form: Wokkel's implementation of data form
|
||||
@return: completed xml_ui
|
||||
"""
|
||||
form_ui = XMLUI("form", "vertical", submit_id=submit_id, session_id=session_id)
|
||||
|
||||
if form.instructions:
|
||||
form_ui.addText('\n'.join(form.instructions), 'instructions')
|
||||
|
||||
|
|
@ -101,6 +99,15 @@ def dataForm2XMLUI(form, submit_id, session_id=None):
|
|||
|
||||
return form_ui
|
||||
|
||||
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
|
||||
|
||||
@param submit_id: callback id to call when submitting form
|
||||
@param session_id: id to return with the data
|
||||
"""
|
||||
form_ui = XMLUI("form", "vertical", submit_id=submit_id, session_id=session_id)
|
||||
return dataForm2Widgets(form_ui, form)
|
||||
|
||||
def dataFormResult2AdvancedList(xmlui, 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
|
||||
|
|
@ -142,16 +149,20 @@ def dataFormResult2AdvancedList(xmlui, form_xml):
|
|||
|
||||
return xmlui
|
||||
|
||||
def dataFormResult2XMLUI(form_xml, session_id=None):
|
||||
def dataFormResult2XMLUI(form_elt, 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
|
||||
@param form_elt: domish.Element of the data form
|
||||
@return: XMLUI interface
|
||||
"""
|
||||
|
||||
xmlui = XMLUI("window", "vertical", session_id=session_id)
|
||||
dataFormResult2AdvancedList(xmlui, form_xml)
|
||||
return xmlui
|
||||
xml_ui = XMLUI("window", "vertical", session_id=session_id)
|
||||
try:
|
||||
dataFormResult2AdvancedList(xml_ui, form_elt)
|
||||
except exceptions.DataError:
|
||||
parsed_form = data_form.Form.fromElement(form_elt)
|
||||
dataForm2Widgets(xml_ui, parsed_form)
|
||||
return xml_ui
|
||||
|
||||
def _cleanValue(value):
|
||||
"""Workaround method to avoid DBus types with D-Bus bridge
|
||||
|
|
|
|||
Loading…
Reference in a new issue