Mercurial > libervia-backend
diff src/tools/xml_tools.py @ 1601:e0a152f2cf6d
core (xmlui), plugin file: added action_extra param to deferXMLUI/deferDialog which is merged to the action data dict when actionNew is called
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 15 Nov 2015 23:11:27 +0100 |
parents | e2ed8009e66e |
children | 5b24d6bf5d15 |
line wrap: on
line diff
--- a/src/tools/xml_tools.py Sat Nov 14 19:54:27 2015 +0100 +++ b/src/tools/xml_tools.py Sun Nov 15 23:11:27 2015 +0100 @@ -1249,12 +1249,14 @@ ) return note_xmlui -def deferXMLUI(host, xmlui, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE): +def deferXMLUI(host, xmlui, action_extra=None, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE): """Create a deferred linked to XMLUI @param xmlui(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 + mainly used to add meta informations (see actionNew doc) @param security_limit: %(doc_security_limit)s @return (data): a deferred which fire the data """ @@ -1266,16 +1268,23 @@ return {} xmlui.submit_id = host.registerCallback(onSubmit, with_data=True, one_shot=True) - host.actionNew({'xmlui': xmlui.toXml()}, profile=profile) + action_data = {'xmlui': xmlui.toXml()} + if action_extra is not None: + action_data.update(action_extra) + host.actionNew(action_data, profile=profile) return xmlui_d -def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CONFIRM, options=None, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE): +def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CONFIRM, options=None, + action_extra=None, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE): """Create a submitable dialog and manage it with a deferred @param message(unicode): message to display @param title(unicode): title of the dialog @param type(unicode): dialog type (C.XMLUI_DIALOG_*) @param options(None, dict): if not None, will be used to update (extend) dialog_opt arguments of XMLUI + @param action_extra(None, dict): extra action to merge with xmlui + mainly used to add meta informations (see actionNew doc) + @param security_limit: %(doc_security_limit)s @param profile: %(doc_profile)s @return (dict): Deferred dict """ @@ -1284,7 +1293,7 @@ if options is not None: dialog_opt.update(options) dialog = XMLUI(C.XMLUI_DIALOG, title=title, dialog_opt=dialog_opt, submit_id='') - return deferXMLUI(host, dialog, security_limit, profile) + return deferXMLUI(host, dialog, action_extra, security_limit, profile) def deferConfirm(*args, **kwargs): """call deferDialog and return a boolean instead of the whole data dict"""