core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
This commit is contained in:
parent
4d15d4a4eb
commit
3857fff974
1 changed files with 30 additions and 6 deletions
|
|
@ -25,6 +25,8 @@ from sat.core import exceptions
|
|||
|
||||
"""This library help manage XML used in SàT (parameters, registration, etc) """
|
||||
|
||||
SAT_FORM_PREFIX ="SAT_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"""
|
||||
|
|
@ -116,6 +118,21 @@ def dataFormResult2XMLUI(form_xml, session_id=None):
|
|||
dataFormResult2AdvancedList(form_ui, form_xml)
|
||||
return form_ui
|
||||
|
||||
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)}
|
||||
|
||||
def XMLUIResultToElt(xmlui_data):
|
||||
""" Construct result domish.Element from XMLUI result
|
||||
@xmlui_data: data returned by frontends for XMLUI form
|
||||
"""
|
||||
form = data_form.Form('result')
|
||||
form.makeFields(XMLUIResult2DataFormResult(xmlui_data))
|
||||
return form.toElement()
|
||||
|
||||
def tupleList2dataForm(values):
|
||||
"""convert a list of tuples (name,value) to a wokkel submit data form"""
|
||||
form = data_form.Form('submit')
|
||||
|
|
|
|||
Loading…
Reference in a new issue