From 5c056c049b54c373af338277f4d59ab3f6d0813c Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 6 Sep 2024 17:45:46 +0200 Subject: [PATCH] tools (xml_tools): add `namespace` argument to `xmlui_result_to_elt`: this allows to specify resulting Form namespace. --- libervia/backend/tools/xml_tools.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/libervia/backend/tools/xml_tools.py b/libervia/backend/tools/xml_tools.py index 63523472..24babeea 100644 --- a/libervia/backend/tools/xml_tools.py +++ b/libervia/backend/tools/xml_tools.py @@ -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()}