Mercurial > libervia-web
changeset 229:e632f77c4219
bridge: asyncGetParamA takes a security_limit argument
browser_side: added support for user param of type "list"
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 08 Oct 2013 13:48:00 +0200 |
parents | 6efd189e8d78 |
children | 266e9678eec0 |
files | browser_side/xmlui.py libervia.py libervia.tac server_side/blog.py |
diffstat | 4 files changed, 23 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/browser_side/xmlui.py Tue Oct 08 13:35:29 2013 +0200 +++ b/browser_side/xmlui.py Tue Oct 08 13:48:00 2013 +0200 @@ -119,6 +119,7 @@ ctrl.setMultipleSelect(elem.getAttribute("multi")=='yes') for option in elem.getElementsByTagName("option"): ctrl.addItem(option.getAttribute("value")) + ctrl.selectItem(value) self.ctrl_list[name] = ({'node_type':node_type, 'control':ctrl}) elif node_type=="button": callback_id = elem.getAttribute("callback_id") @@ -128,10 +129,12 @@ print("FIXME FIXME FIXME: type [%s] is not implemented" % node_type) #FIXME ! raise NotImplementedError if self.node_type == 'param': - if isinstance(ctrl,TextBoxBase): + if isinstance(ctrl, TextBoxBase): ctrl.addChangeListener(self.onParamChange) elif isinstance(ctrl, CheckBox): ctrl.addClickListener(self.onParamChange) + elif isinstance(ctrl, ListBox): + ctrl.addChangeListener(self.onParamChange) ctrl._param_category = self._current_category ctrl._param_name = name parent.append(ctrl) @@ -217,7 +220,7 @@ for field in fields: ctrl = self.ctrl_list[field] if isinstance(ctrl['control'],ListBox): - data[field] = '\t'.join(ctrl['control'].getSelectedValues()) + data[field] = '\t'.join(ctrl['control'].getSelectedItemText()) elif isinstance(ctrl['control'],CheckBox): data[field] = "true" if ctrl['control'].isChecked() else "false" else: @@ -240,7 +243,7 @@ for ctrl_name in self.ctrl_list: ctrl = self.ctrl_list[ctrl_name] if isinstance(ctrl['control'], ListBox): - data.append((ctrl_name, ctrl['control'].getValue())) + data.append((ctrl_name, '\t'.join(ctrl['control'].getSelectedItemText()))) elif isinstance(ctrl['control'], CheckBox): data.append((ctrl_name, "true" if ctrl['control'].isChecked() else "false")) else: @@ -262,6 +265,8 @@ for ctrl in self.param_changed: if isinstance(ctrl, CheckBox): value = "true" if ctrl.isChecked() else "false" + elif isinstance(ctrl, ListBox): + value = '\t'.join(ctrl.getSelectedItemText()) else: value = ctrl.getText() self.host.bridge.call('setParam', None, ctrl._param_name, value, ctrl._param_category)
--- a/libervia.py Tue Oct 08 13:35:29 2013 +0200 +++ b/libervia.py Tue Oct 08 13:48:00 2013 +0200 @@ -105,8 +105,8 @@ "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getCard", - "getEntityData", "getParamsUI", "setParam", "launchAction", "disconnect", - "chatStateComposing" + "getEntityData", "getParamsUI", "asyncGetParamA", "setParam", "launchAction", + "disconnect", "chatStateComposing" ]) class BridgeSignals(LiberviaJsonProxy): @@ -390,7 +390,7 @@ self.bridge.call('getMassiveLastMblogs', lib_wid.massiveInsert, 'ALL', [], 10) else: self.bridge.call('getMassiveLastMblogs', lib_wid.massiveInsert, 'GROUP', lib_wid.accepted_groups, 10) - + #we ask for our own microblogs: self.bridge.call('getMassiveLastMblogs', self._ownBlogsFills, 'JID', [self.whoami.bare], 10)
--- a/libervia.tac Tue Oct 08 13:35:29 2013 +0200 +++ b/libervia.tac Tue Oct 08 13:48:00 2013 +0200 @@ -410,6 +410,12 @@ return d + def jsonrpc_asyncGetParamA(self, param, category, attribute="value"): + """Return the parameter value for profile""" + profile = ISATSession(self.session).profile + d = self.asyncBridgeCall("asyncGetParamA", param, category, attribute, SECURITY_LIMIT, profile_key=profile) + return d + def jsonrpc_setParam(self, name, value, category): profile = ISATSession(self.session).profile if category in self.authorized_params and name in self.authorized_params[category]:
--- a/server_side/blog.py Tue Oct 08 13:35:29 2013 +0200 +++ b/server_side/blog.py Tue Oct 08 13:48:00 2013 +0200 @@ -26,6 +26,10 @@ from twisted.words.protocols.jabber.jid import JID from datetime import datetime +# Security limit for Libervia server_side +SECURITY_LIMIT = -1 + + class MicroBlog(Resource): isLeaf = True @@ -61,9 +65,9 @@ d2 = defer.Deferred() d2.addCallbacks(self.render_html_blog, self.render_error_blog, [request, prof_found], None, [request, prof_found], None) self.host.bridge.getLastGroupBlogs(pub_jid.userhost(), 10, 'libervia', d2.callback, d2.errback) - + d1 = defer.Deferred() - JID(self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', prof_found, callback=d1.callback, errback=d1.errback)) + JID(self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', SECURITY_LIMIT, prof_found, callback=d1.callback, errback=d1.errback)) d1.addCallbacks(got_jid) return server.NOT_DONE_YET