# HG changeset patch # User souliane # Date 1388755141 -3600 # Node ID c12c9a1acf2f4bf222fa56601b3cd7116eba498d # Parent bbadd490e63cef8e5931ffa38875c7bf3e1f3caf server_side: added support for paramsRegisterApp to define frontend's specific parameters like "Enable unibox" diff -r bbadd490e63c -r c12c9a1acf2f libervia.py --- a/libervia.py Fri Jan 03 14:14:34 2014 +0100 +++ b/libervia.py Fri Jan 03 14:19:01 2014 +0100 @@ -110,7 +110,7 @@ class RegisterCall(LiberviaJsonProxy): def __init__(self): LiberviaJsonProxy.__init__(self, "/register_api", - ["isRegistered", "isConnected", "connect"]) + ["isRegistered", "isConnected", "connect", "registerParams"]) class BridgeCall(LiberviaJsonProxy): @@ -180,6 +180,7 @@ RootPanel().add(self.panel) DOM.addEventPreview(self) self._register = RegisterCall() + self._register.call('registerParams', None) self._register.call('isRegistered', self._isRegisteredCB) self.initialised = False self.init_cache = [] # used to cache events until initialisation is done @@ -348,7 +349,6 @@ # this would eventually set the browser saved password Timer(5, lambda: self._register_box._form.login_pass_box.setFocus(True)) - def _actionCb(self, data): if not data: # action was a one shot, nothing to do diff -r bbadd490e63c -r c12c9a1acf2f libervia.tac --- a/libervia.tac Fri Jan 03 14:14:34 2014 +0100 +++ b/libervia.tac Fri Jan 03 14:19:01 2014 +0100 @@ -42,6 +42,7 @@ from zope.interface import Interface, Attribute, implements from xml.dom import minidom from constants import Const +from sat.core.i18n import _, D_ class ISATSession(Interface): @@ -441,7 +442,7 @@ def jsonrpc_getParamsUI(self): """Return the parameters XML for profile""" profile = ISATSession(self.session).profile - d = self.asyncBridgeCall("getParams", Const.SECURITY_LIMIT, profile) + d = self.asyncBridgeCall("getParams", Const.SECURITY_LIMIT, Const.APP_NAME, profile) def setAuthorizedParams(d): if self.authorized_params is None: @@ -530,13 +531,14 @@ Render method with some hacks: - if login is requested, try to login with form data - except login, every method is jsonrpc - - user doesn't need to be authentified for isRegistered, but must be for all other methods + - user doesn't need to be authentified for isRegistered or registerParams, but must be for all other methods """ if request.postpath==['login']: return self.login(request) _session = request.getSession() parsed = jsonrpclib.loads(request.content.read()) - if parsed.get("method")!="isRegistered": + method = parsed.get("method") + if method != "isRegistered" and method != "registerParams": #if we don't call login or isRegistered, we need to be identified profile = ISATSession(_session).profile if not profile: @@ -718,6 +720,25 @@ profile = ISATSession(_session).profile return bool(profile) + def jsonrpc_registerParams(self): + """Register the frontend specific parameters""" + params = """ + + + + + + + + """ % { + 'category_name': Const.ENABLE_UNIBOX_KEY, + 'category_label': _(Const.ENABLE_UNIBOX_KEY), + 'param_name': Const.ENABLE_UNIBOX_PARAM, + 'param_label': _(Const.ENABLE_UNIBOX_PARAM) + } + + self.sat_host.bridge.paramsRegisterApp(params, Const.SECURITY_LIMIT, Const.APP_NAME) + class SignalHandler(jsonrpc.JSONRPC): @@ -978,7 +999,6 @@ def stop(self): reactor.stop() - registerAdapter(SATSession, server.Session, ISATSession) application = service.Application(Const.APP_NAME) service = Libervia()