Mercurial > libervia-web
diff libervia.tac @ 318:c12c9a1acf2f
server_side: added support for paramsRegisterApp to define frontend's specific parameters like "Enable unibox"
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 03 Jan 2014 14:19:01 +0100 |
parents | bbadd490e63c |
children | 0b7934e75e76 |
line wrap: on
line diff
--- 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 = """ + <params> + <individual> + <category name="%(category_name)s" label="%(category_label)s"> + <param name="%(param_name)s" label="%(param_label)s" value="true" type="bool" security="0"/> + </category> + </individual> + </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()