frontends (jp): onActionNew displays xmlui message if no meta_type is defined and xmlui is defined
This commit is contained in:
parent
0eaf531608
commit
c18f64f4fb
2 changed files with 22 additions and 2 deletions
|
|
@ -37,6 +37,8 @@ from sat_frontends.bridge.DBus import DBusBridgeFrontend
|
||||||
from sat.core import exceptions
|
from sat.core import exceptions
|
||||||
import sat_frontends.jp
|
import sat_frontends.jp
|
||||||
from sat_frontends.jp.constants import Const as C
|
from sat_frontends.jp.constants import Const as C
|
||||||
|
import xml.etree.ElementTree as ET # FIXME: used temporarily to manage XMLUI
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import progressbar
|
import progressbar
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
@ -621,7 +623,12 @@ class CommandAnswering(CommandBase):
|
||||||
try:
|
try:
|
||||||
action_type = action_data['meta_type']
|
action_type = action_data['meta_type']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
try:
|
||||||
|
xml_ui = action_data["xmlui"]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.onXMLUI(xml_ui)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
callback = self.action_callbacks[action_type]
|
callback = self.action_callbacks[action_type]
|
||||||
|
|
@ -630,6 +637,19 @@ class CommandAnswering(CommandBase):
|
||||||
else:
|
else:
|
||||||
callback(action_data, action_id, security_limit, profile)
|
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):
|
def connected(self):
|
||||||
"""Auto reply to confirmations requests"""
|
"""Auto reply to confirmations requests"""
|
||||||
self.need_loop = True
|
self.need_loop = True
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ URL_REDIRECT_PREFIX = 'url_redirect_'
|
||||||
__commands__ = ["Blog"]
|
__commands__ = ["Blog"]
|
||||||
|
|
||||||
|
|
||||||
class Import(base.CommandBase):
|
class Import(base.CommandAnswering):
|
||||||
def __init__(self, host):
|
def __init__(self, host):
|
||||||
super(Import, self).__init__(host, 'import', use_progress=True, help=_(u'import an external blog'))
|
super(Import, self).__init__(host, 'import', use_progress=True, help=_(u'import an external blog'))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue