Mercurial > libervia-backend
diff libervia/backend/tools/xml_tools.py @ 4299:d2deddd6df44
tools (xml_tools): add `namespace` argument to `xmlui_result_to_elt`:
this allows to specify resulting Form namespace.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Sep 2024 17:45:46 +0200 |
parents | 0d7bb4df2343 |
children |
line wrap: on
line diff
--- a/libervia/backend/tools/xml_tools.py Fri Sep 06 17:44:08 2024 +0200 +++ b/libervia/backend/tools/xml_tools.py Fri Sep 06 17:45:46 2024 +0200 @@ -469,13 +469,14 @@ 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 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()}