comparison 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
comparison
equal deleted inserted replaced
4298:060d695ae98e 4299:d2deddd6df44
467 def is_xmlui_cancelled(raw_xmlui): 467 def is_xmlui_cancelled(raw_xmlui):
468 """Tell if an XMLUI has been cancelled by checking raw XML""" 468 """Tell if an XMLUI has been cancelled by checking raw XML"""
469 return C.bool(raw_xmlui.get("cancelled", C.BOOL_FALSE)) 469 return C.bool(raw_xmlui.get("cancelled", C.BOOL_FALSE))
470 470
471 471
472 def xmlui_result_to_elt(xmlui_data): 472 def xmlui_result_to_elt(xmlui_data: dict, namespace: str | None = None):
473 """Construct result domish.Element from XMLUI result. 473 """Construct result domish.Element from XMLUI result.
474 474
475 @param xmlui_data (dict): data returned by frontends for XMLUI form 475 @param xmlui_data: data returned by frontends for XMLUI form
476 @param namespace: namespace to use for the form.
476 @return: domish.Element 477 @return: domish.Element
477 """ 478 """
478 form = data_form.Form("submit") 479 form = data_form.Form("submit", formNamespace=namespace)
479 form.makeFields(xmlui_result_2_data_form_result(xmlui_data)) 480 form.makeFields(xmlui_result_2_data_form_result(xmlui_data))
480 return form.toElement() 481 return form.toElement()
481 482
482 483
483 def tuple_list_2_data_form(values): 484 def tuple_list_2_data_form(values):
1740 return xmlui_d 1741 return xmlui_d
1741 1742
1742 1743
1743 def defer_xmlui( 1744 def defer_xmlui(
1744 host, 1745 host,
1745 xmlui, 1746 xmlui: XMLUI,
1746 action_extra=None, 1747 action_extra: dict | None = None,
1747 security_limit=C.NO_SECURITY_LIMIT, 1748 security_limit: int = C.NO_SECURITY_LIMIT,
1748 chained=False, 1749 chained: bool = False,
1749 profile=C.PROF_KEY_NONE, 1750 profile: str = C.PROF_KEY_NONE,
1750 ): 1751 ) -> defer.Deferred[dict]:
1751 """Create a deferred linked to XMLUI 1752 """Create a deferred linked to XMLUI
1752 1753
1753 @param xmlui(XMLUI): instance of the XMLUI 1754 @param xmlui: instance of the XMLUI
1754 Must be an XMLUI that you can submit, with submit_id set to '' 1755 Must be an XMLUI that you can submit, with submit_id set to ''
1755 @param profile: %(doc_profile)s 1756 @param profile: %(doc_profile)s
1756 @param action_extra(None, dict): extra action to merge with xmlui 1757 @param action_extra: extra action to merge with xmlui
1757 mainly used to add meta informations (see action_new doc) 1758 mainly used to add meta informations (see action_new doc)
1758 @param security_limit: %(doc_security_limit)s 1759 @param security_limit: %(doc_security_limit)s
1759 @param chained(bool): True if the Deferred result must be returned to the frontend 1760 @param chained: True if the Deferred result must be returned to the frontend
1760 useful when backend is in a series of dialogs with an ui 1761 useful when backend is in a series of dialogs with an ui
1761 @return (data): a deferred which fire the data 1762 @return: a deferred which fire the data
1762 """ 1763 """
1763 xmlui_d = deferred_ui(host, xmlui, chained) 1764 xmlui_d = deferred_ui(host, xmlui, chained)
1764 action_data = {"xmlui": xmlui.toXml()} 1765 action_data = {"xmlui": xmlui.toXml()}
1765 if action_extra is not None: 1766 if action_extra is not None:
1766 action_data.update(action_extra) 1767 action_data.update(action_extra)