Mercurial > libervia-web
changeset 140:09a512d9a0c0
server side: fixed getHistory call and action result management
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 14 Nov 2012 22:24:07 +0100 |
parents | b6658f3ac8a0 |
children | a5e9aa1f9c0c |
files | libervia.tac |
diffstat | 1 files changed, 21 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia.tac Tue Oct 30 00:52:30 2012 +0100 +++ b/libervia.tac Wed Nov 14 22:24:07 2012 +0100 @@ -93,33 +93,36 @@ return NoResource() class SATActionIDHandler(object): - """Manage SàT action id lifecycle""" - ID_LIFETIME = 30 #after this time (in seconds), id will be suppressed and action result will be ignored + """Manage SàT action action_id lifecycle""" + ID_LIFETIME = 30 #after this time (in seconds), action_id will be suppressed and action result will be ignored def __init__(self): self.waiting_ids = {} - def waitForId(self, id, callback, *args, **kwargs): + def waitForId(self, callback, action_id, profile, *args, **kwargs): """Wait for an action result - @param id: id to wait for @param callback: method to call when action gave a result back + @param action_id: action_id to wait for + @param profile: %(doc_profile)s @param *args: additional argument to pass to callback @param **kwargs: idem""" - self.waiting_ids[id] = (callback, args, kwargs) - reactor.callLater(self.ID_LIFETIME, self.purgeID, id) + action_tuple = (action_id, profile) + self.waiting_ids[action_tuple] = (callback, args, kwargs) + reactor.callLater(self.ID_LIFETIME, self.purgeID, action_tuple) - def purgeID(self, id): - """Called when an id has not be handled in time""" - if id in self.waiting_ids: - warning ("action of id %s has not been managed, id is now ignored" % id) - del self.waiting_ids[id] + def purgeID(self, action_tuple): + """Called when an action_id has not be handled in time""" + if action_tuple in self.waiting_ids: + warning ("action of action_id %s [%s] has not been managed, action_id is now ignored" % action_tuple) + del self.waiting_ids[action_tuple] - def actionResultCb(self, answer_type, id, data): + def actionResultCb(self, answer_type, action_id, data, profile): """Manage the actionResult signal""" - if id in self.waiting_ids: - callback, args, kwargs = self.waiting_ids[id] - del self.waiting_ids[id] - callback(answer_type, id, data, *args, **kwargs) + action_tuple = (action_id, profile) + if action_tuple in self.waiting_ids: + callback, args, kwargs = self.waiting_ids[action_tuple] + del self.waiting_ids[action_tuple] + callback(answer_type, action_id, data, *args, **kwargs) class MethodHandler(jsonrpc.JSONRPC): @@ -246,7 +249,7 @@ error("Trying to get history from a different jid, maybe a hack attempt ?") return {} d = defer.Deferred() - self.sat_host.bridge.getHistory(from_jid, to_jid, size, between, callback=d.callback, errback=d.errback) + self.sat_host.bridge.getHistory(from_jid, to_jid, size, between, profile, callback=d.callback, errback=d.errback) def show(result_dbus): result = [] for line in result_dbus: @@ -452,7 +455,7 @@ self.sat_host.bridge.setParam("Password", password, "Connection", profile) #and the account action_id = self.sat_host.bridge.registerNewAccount(login, password, email, _NEW_ACCOUNT_DOMAIN, 5222) - self.sat_host.action_handler.waitForId(action_id, self._postAccountCreation, profile) + self.sat_host.action_handler.waitForId(self._postAccountCreation, action_id, profile) #time to send the email