comparison src/tools/xml_tools.py @ 1737:ad5da569ecf4

core (xmlui): fixed deferConfirm
author Goffi <goffi@goffi.org>
date Tue, 15 Dec 2015 12:41:07 +0100
parents 3739f7779f17
children 681fe91abcc0
comparison
equal deleted inserted replaced
1736:3739f7779f17 1737:ad5da569ecf4
1288 action_data.update(action_extra) 1288 action_data.update(action_extra)
1289 host.actionNew(action_data, security_limit=security_limit, keep_id=xmlui.submit_id, profile=profile) 1289 host.actionNew(action_data, security_limit=security_limit, keep_id=xmlui.submit_id, profile=profile)
1290 return xmlui_d 1290 return xmlui_d
1291 1291
1292 def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CONFIRM, options=None, 1292 def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CONFIRM, options=None,
1293 action_extra=None, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE): 1293 action_extra=None, security_limit=C.NO_SECURITY_LIMIT, chained=False, profile=C.PROF_KEY_NONE):
1294 """Create a submitable dialog and manage it with a deferred 1294 """Create a submitable dialog and manage it with a deferred
1295 1295
1296 @param message(unicode): message to display 1296 @param message(unicode): message to display
1297 @param title(unicode): title of the dialog 1297 @param title(unicode): title of the dialog
1298 @param type(unicode): dialog type (C.XMLUI_DIALOG_*) 1298 @param type(unicode): dialog type (C.XMLUI_DIALOG_*)
1299 @param options(None, dict): if not None, will be used to update (extend) dialog_opt arguments of XMLUI 1299 @param options(None, dict): if not None, will be used to update (extend) dialog_opt arguments of XMLUI
1300 @param action_extra(None, dict): extra action to merge with xmlui 1300 @param action_extra(None, dict): extra action to merge with xmlui
1301 mainly used to add meta informations (see actionNew doc) 1301 mainly used to add meta informations (see actionNew doc)
1302 @param security_limit: %(doc_security_limit)s 1302 @param security_limit: %(doc_security_limit)s
1303 @param chained(bool): True if the Deferred result must be returned to the frontend
1304 useful when backend is in a series of dialogs with an ui
1303 @param profile: %(doc_profile)s 1305 @param profile: %(doc_profile)s
1304 @return (dict): Deferred dict 1306 @return (dict): Deferred dict
1305 """ 1307 """
1306 assert profile is not None 1308 assert profile is not None
1307 dialog_opt = {'type': type_, 'message': message} 1309 dialog_opt = {'type': type_, 'message': message}
1308 if options is not None: 1310 if options is not None:
1309 dialog_opt.update(options) 1311 dialog_opt.update(options)
1310 dialog = XMLUI(C.XMLUI_DIALOG, title=title, dialog_opt=dialog_opt, submit_id='') 1312 dialog = XMLUI(C.XMLUI_DIALOG, title=title, dialog_opt=dialog_opt, submit_id='')
1311 return deferXMLUI(host, dialog, action_extra, security_limit, profile) 1313 return deferXMLUI(host, dialog, action_extra, security_limit, chained, profile)
1312 1314
1313 def deferConfirm(*args, **kwargs): 1315 def deferConfirm(*args, **kwargs):
1314 """call deferDialog and return a boolean instead of the whole data dict""" 1316 """call deferDialog and return a boolean instead of the whole data dict"""
1315 d = deferDialog(*args, **kwargs) 1317 d = deferDialog(*args, **kwargs)
1316 d.addCallback(lambda data: C.bool(data['answer'])) 1318 d.addCallback(lambda data: C.bool(data['answer']))