Mercurial > libervia-backend
changeset 1840:9eabf7fadfdd
frontends (jp): onActionNew displays xmlui message if no meta_type is defined and xmlui is defined
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 04 Feb 2016 11:48:37 +0100 |
parents | cdecf553e051 |
children | 7717975b3ec3 |
files | frontends/src/jp/base.py frontends/src/jp/cmd_blog.py |
diffstat | 2 files changed, 22 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/jp/base.py Thu Feb 04 11:44:43 2016 +0100 +++ b/frontends/src/jp/base.py Thu Feb 04 11:48:37 2016 +0100 @@ -37,6 +37,8 @@ from sat.core import exceptions import sat_frontends.jp from sat_frontends.jp.constants import Const as C +import xml.etree.ElementTree as ET # FIXME: used temporarily to manage XMLUI + try: import progressbar except ImportError: @@ -621,7 +623,12 @@ try: action_type = action_data['meta_type'] except KeyError: - pass + try: + xml_ui = action_data["xmlui"] + except KeyError: + pass + else: + self.onXMLUI(xml_ui) else: try: callback = self.action_callbacks[action_type] @@ -630,6 +637,19 @@ else: callback(action_data, action_id, security_limit, profile) + def onXMLUI(self, xml_ui): + """Display a dialog received from the backend. + + @param xml_ui (unicode): dialog XML representation + """ + # FIXME: we temporarily use ElementTree, but a real XMLUI managing module + # should be available in the future + # TODO: XMLUI module + ui = ET.fromstring(xml_ui.encode('utf-8')) + dialog = ui.find("dialog") + if dialog is not None: + self.disp(dialog.findtext("message"), error=dialog.get("level") == "error") + def connected(self): """Auto reply to confirmations requests""" self.need_loop = True
--- a/frontends/src/jp/cmd_blog.py Thu Feb 04 11:44:43 2016 +0100 +++ b/frontends/src/jp/cmd_blog.py Thu Feb 04 11:48:37 2016 +0100 @@ -27,7 +27,7 @@ __commands__ = ["Blog"] -class Import(base.CommandBase): +class Import(base.CommandAnswering): def __init__(self, host): super(Import, self).__init__(host, 'import', use_progress=True, help=_(u'import an external blog'))