Mercurial > libervia-web
comparison libervia_server/__init__.py @ 333:c01397d18026
server side: paramsXml2xmlUI is now parasXML2XMLUI + improved lisibility in getParamsUI
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 04 Feb 2014 16:49:20 +0100 |
parents | 06a48d805547 |
children | 629c99bbd031 |
comparison
equal
deleted
inserted
replaced
332:6abd099c7007 | 333:c01397d18026 |
---|---|
43 | 43 |
44 from constants import Const | 44 from constants import Const |
45 from libervia_server.blog import MicroBlog | 45 from libervia_server.blog import MicroBlog |
46 from sat_frontends.bridge.DBus import DBusBridgeFrontend, BridgeExceptionNoService | 46 from sat_frontends.bridge.DBus import DBusBridgeFrontend, BridgeExceptionNoService |
47 from sat.core.i18n import _, D_ | 47 from sat.core.i18n import _, D_ |
48 from sat.tools.xml_tools import paramsXML2XMLUI | |
48 | 49 |
49 | 50 |
50 class ISATSession(Interface): | 51 class ISATSession(Interface): |
51 profile = Attribute("Sat profile") | 52 profile = Attribute("Sat profile") |
52 jid = Attribute("JID associated with the profile") | 53 jid = Attribute("JID associated with the profile") |
444 def jsonrpc_getParamsUI(self): | 445 def jsonrpc_getParamsUI(self): |
445 """Return the parameters XML for profile""" | 446 """Return the parameters XML for profile""" |
446 profile = ISATSession(self.session).profile | 447 profile = ISATSession(self.session).profile |
447 d = self.asyncBridgeCall("getParams", Const.SECURITY_LIMIT, Const.APP_NAME, profile) | 448 d = self.asyncBridgeCall("getParams", Const.SECURITY_LIMIT, Const.APP_NAME, profile) |
448 | 449 |
449 def setAuthorizedParams(d): | 450 def setAuthorizedParams(params_xml): |
450 if self.authorized_params is None: | 451 if self.authorized_params is None: |
451 self.authorized_params = {} | 452 self.authorized_params = {} |
452 for cat in minidom.parseString(d.encode('utf-8')).getElementsByTagName("category"): | 453 for cat in minidom.parseString(params_xml.encode('utf-8')).getElementsByTagName("category"): |
453 params = cat.getElementsByTagName("param") | 454 params = cat.getElementsByTagName("param") |
454 params_list = [param.getAttribute("name") for param in params] | 455 params_list = [param.getAttribute("name") for param in params] |
455 self.authorized_params[cat.getAttribute("name")] = params_list | 456 self.authorized_params[cat.getAttribute("name")] = params_list |
456 if self.authorized_params: | 457 if self.authorized_params: |
457 return d | 458 return params_xml |
458 else: | 459 else: |
459 return None | 460 return None |
460 | 461 |
461 d.addCallback(setAuthorizedParams) | 462 d.addCallback(setAuthorizedParams) |
462 | 463 |
463 from sat.tools.xml_tools import paramsXml2xmlUI | 464 d.addCallback(lambda params_xml: paramsXML2XMLUI(params_xml) if params_xml else "") |
464 d.addCallback(lambda d: paramsXml2xmlUI(d) if d else "") | |
465 | 465 |
466 return d | 466 return d |
467 | 467 |
468 def jsonrpc_asyncGetParamA(self, param, category, attribute="value"): | 468 def jsonrpc_asyncGetParamA(self, param, category, attribute="value"): |
469 """Return the parameter value for profile""" | 469 """Return the parameter value for profile""" |