tools (xml_tools): add namespace argument to xmlui_result_to_elt:

this allows to specify resulting Form namespace.
This commit is contained in:
Goffi 2024-09-06 17:45:46 +02:00
commit 5c056c049b

View file

@ -469,13 +469,14 @@ def is_xmlui_cancelled(raw_xmlui):
return C.bool(raw_xmlui.get("cancelled", C.BOOL_FALSE))
def xmlui_result_to_elt(xmlui_data):
def xmlui_result_to_elt(xmlui_data: dict, namespace: str | None = None):
"""Construct result domish.Element from XMLUI result.
@param xmlui_data (dict): data returned by frontends for XMLUI form
@param xmlui_data: data returned by frontends for XMLUI form
@param namespace: namespace to use for the form.
@return: domish.Element
"""
form = data_form.Form("submit")
form = data_form.Form("submit", formNamespace=namespace)
form.makeFields(xmlui_result_2_data_form_result(xmlui_data))
return form.toElement()
@ -1742,23 +1743,23 @@ def deferred_ui(host, xmlui, chained=False):
def defer_xmlui(
host,
xmlui,
action_extra=None,
security_limit=C.NO_SECURITY_LIMIT,
chained=False,
profile=C.PROF_KEY_NONE,
):
xmlui: XMLUI,
action_extra: dict | None = None,
security_limit: int = C.NO_SECURITY_LIMIT,
chained: bool = False,
profile: str = C.PROF_KEY_NONE,
) -> defer.Deferred[dict]:
"""Create a deferred linked to XMLUI
@param xmlui(XMLUI): instance of the XMLUI
@param xmlui: instance of the XMLUI
Must be an XMLUI that you can submit, with submit_id set to ''
@param profile: %(doc_profile)s
@param action_extra(None, dict): extra action to merge with xmlui
@param action_extra: extra action to merge with xmlui
mainly used to add meta informations (see action_new doc)
@param security_limit: %(doc_security_limit)s
@param chained(bool): True if the Deferred result must be returned to the frontend
@param chained: True if the Deferred result must be returned to the frontend
useful when backend is in a series of dialogs with an ui
@return (data): a deferred which fire the data
@return: a deferred which fire the data
"""
xmlui_d = deferred_ui(host, xmlui, chained)
action_data = {"xmlui": xmlui.toXml()}