Mercurial > libervia-backend
comparison src/plugins/plugin_misc_groupblog.py @ 1243:b4a264915ea9
plugins groupblogs: fixes the massive retrieval callback (loop variable was misused in a lambda callback)
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 19 Oct 2014 02:48:11 +0200 |
parents | 0b87d029f0a3 |
children | bb30bf3ae932 |
comparison
equal
deleted
inserted
replaced
1242:f584fbda4773 | 1243:b4a264915ea9 |
---|---|
683 else: | 683 else: |
684 raise UnknownType | 684 raise UnknownType |
685 | 685 |
686 data = {publisher: self.getNodeName(publisher) for publisher in jids} | 686 data = {publisher: self.getNodeName(publisher) for publisher in jids} |
687 d_dict = yield self.host.plugins["XEP-0060"].getItemsFromMany(client.item_access_pubsub, data, max_items=max_items, profile_key=profile) | 687 d_dict = yield self.host.plugins["XEP-0060"].getItemsFromMany(client.item_access_pubsub, data, max_items=max_items, profile_key=profile) |
688 | |
689 def cb(jid): | |
690 def res(gbdata): | |
691 return (jid.full(), gbdata) | |
692 return res | |
693 | |
688 for publisher, d in d_dict.items(): | 694 for publisher, d in d_dict.items(): |
689 d.addCallback(self._itemsConstruction, publisher, client) | 695 d.addCallback(self._itemsConstruction, publisher, client) |
690 d.addCallback(lambda gbdata: (publisher.full(), gbdata)) | 696 d.addCallback(cb(publisher)) |
691 # consume the failure "StanzaError with condition u'item-not-found'" | 697 result = yield defer.DeferredList(d_dict.values(), consumeErrors=False) |
692 # when the node doesn't exist (e.g that JID hasn't posted any message) | |
693 result = yield defer.DeferredList(d_dict.values(), consumeErrors=True) | |
694 defer.returnValue({value[0]: value[1] for success, value in result if success}) | 698 defer.returnValue({value[0]: value[1] for success, value in result if success}) |
695 | 699 |
696 def subscribeGroupBlog(self, pub_jid, profile_key=C.PROF_KEY_NONE): | 700 def subscribeGroupBlog(self, pub_jid, profile_key=C.PROF_KEY_NONE): |
697 def initialised(result): | 701 def initialised(result): |
698 profile, client = result | 702 profile, client = result |
737 else: | 741 else: |
738 raise UnknownType | 742 raise UnknownType |
739 | 743 |
740 node_ids = [self.getNodeName(publisher) for publisher in jids] | 744 node_ids = [self.getNodeName(publisher) for publisher in jids] |
741 d_list = yield self.host.plugins["XEP-0060"].subscribeToMany(client.item_access_pubsub, node_ids, profile_key=profile_key) | 745 d_list = yield self.host.plugins["XEP-0060"].subscribeToMany(client.item_access_pubsub, node_ids, profile_key=profile_key) |
742 # consume the failure "StanzaError with condition u'item-not-found'" | 746 result = yield defer.DeferredList(d_list, consumeErrors=False) |
743 # when the node doesn't exist (e.g that JID hasn't posted any message) | |
744 result = yield defer.DeferredList(d_list, consumeErrors=True) | |
745 defer.returnValue(result) | 747 defer.returnValue(result) |
746 | 748 |
747 def deleteAllGroupBlogsAndComments(self, profile_key=C.PROF_KEY_NONE): | 749 def deleteAllGroupBlogsAndComments(self, profile_key=C.PROF_KEY_NONE): |
748 """Delete absolutely all the microblog data that the user has posted""" | 750 """Delete absolutely all the microblog data that the user has posted""" |
749 calls = [self.deleteAllGroupBlogs(profile_key), self.deleteAllGroupBlogsComments(profile_key)] | 751 calls = [self.deleteAllGroupBlogs(profile_key), self.deleteAllGroupBlogsComments(profile_key)] |