Mercurial > libervia-backend
comparison src/plugins/plugin_misc_groupblog.py @ 326:0f9925193586
core, plugin mblog: fixed some exceptions
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 17 May 2011 01:34:17 +0200 |
parents | f56108eb2880 |
children | 2572351d875a |
comparison
equal
deleted
inserted
replaced
325:d62eb9003375 | 326:0f9925193586 |
---|---|
63 """This class use a PubSub Collection to manage roster access on microblog""" | 63 """This class use a PubSub Collection to manage roster access on microblog""" |
64 | 64 |
65 def __init__(self, host): | 65 def __init__(self, host): |
66 info(_("Group blog plugin initialization")) | 66 info(_("Group blog plugin initialization")) |
67 self.host = host | 67 self.host = host |
68 self._blog_nodes={} | 68 self._blog_nodes={} #keep association betweek [profile][node] and [groups] |
69 for i in range(1,21): | 69 for i in range(1,21): |
70 self.host.plugins["XEP-0163"].addPEPEvent("MICROBLOG_%02d" % i, NS_MICROBLOG % i, self.groupblogCB, None) | 70 self.host.plugins["XEP-0163"].addPEPEvent("MICROBLOG_%02d" % i, NS_MICROBLOG % i, self.groupblogCB, None) |
71 | 71 |
72 host.bridge.addMethod("cleanBlogCollection", ".communication", in_sign='s', out_sign='', | 72 host.bridge.addMethod("cleanBlogCollection", ".communication", in_sign='s', out_sign='', |
73 method=self.cleanBlogCollection, | 73 method=self.cleanBlogCollection, |
99 | 99 |
100 def groupblogCB(self, itemsEvent, profile): | 100 def groupblogCB(self, itemsEvent, profile): |
101 for item in itemsEvent.items: | 101 for item in itemsEvent.items: |
102 microblog_data = self.host.plugins["XEP-0277"]._item2mbdata(item) | 102 microblog_data = self.host.plugins["XEP-0277"]._item2mbdata(item) |
103 microblog_data["node"] = itemsEvent.nodeIdentifier | 103 microblog_data["node"] = itemsEvent.nodeIdentifier |
104 microblog_data["groups"] = "\n".join(self._blog_nodes[profile].get(itemsEvent.nodeIdentifier, [])) | 104 try: |
105 microblog_data["groups"] = "\n".join(self._blog_nodes[profile].get(itemsEvent.nodeIdentifier, [])) | |
106 except KeyError: | |
107 pass | |
105 self.host.bridge.personalEvent(itemsEvent.sender.full(), "MICROBLOG", microblog_data, profile) | 108 self.host.bridge.personalEvent(itemsEvent.sender.full(), "MICROBLOG", microblog_data, profile) |
106 | 109 |
107 def _getRootNode(self, entity): | 110 def _getRootNode(self, entity): |
108 return "%(entity)s_%(root_suff)s" % {'entity':entity.userhost(), 'root_suff':MBLOG_COLLECTION} | 111 return "%(entity)s_%(root_suff)s" % {'entity':entity.userhost(), 'root_suff':MBLOG_COLLECTION} |
109 | 112 |
314 d = defer.DeferredList([self.host.plugins["XEP-0060"].deleteNode(pubsub_ent, node, profile) for node in to_delete]) | 317 d = defer.DeferredList([self.host.plugins["XEP-0060"].deleteNode(pubsub_ent, node, profile) for node in to_delete]) |
315 d.addCallback(check_deletion) | 318 d.addCallback(check_deletion) |
316 | 319 |
317 def cleanBlogCollection(self, profile_key='@DEFAULT@'): | 320 def cleanBlogCollection(self, profile_key='@DEFAULT@'): |
318 """Remove blog nodes not referenced in config node""" | 321 """Remove blog nodes not referenced in config node""" |
319 debug(_('Getting mblog nodes')) | 322 debug(_('Cleaning mblog nodes')) |
320 profile = self.host.memory.getProfileName(profile_key) | 323 profile = self.host.memory.getProfileName(profile_key) |
321 if not profile: | 324 if not profile: |
322 error(_("Unknown profile")) | 325 error(_("Unknown profile")) |
323 return {} | 326 return {} |
324 | 327 |