changeset 326:0f9925193586

core, plugin mblog: fixed some exceptions
author Goffi <goffi@goffi.org>
date Tue, 17 May 2011 01:34:17 +0200
parents d62eb9003375
children 7c9784658163
files src/plugins/plugin_misc_groupblog.py src/tools/memory.py
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_misc_groupblog.py	Wed May 11 19:49:55 2011 +0200
+++ b/src/plugins/plugin_misc_groupblog.py	Tue May 17 01:34:17 2011 +0200
@@ -65,7 +65,7 @@
     def __init__(self, host):
         info(_("Group blog plugin initialization"))
         self.host = host
-        self._blog_nodes={}
+        self._blog_nodes={} #keep association betweek [profile][node] and [groups]
         for i in range(1,21):
             self.host.plugins["XEP-0163"].addPEPEvent("MICROBLOG_%02d" % i, NS_MICROBLOG % i, self.groupblogCB, None)
 
@@ -101,7 +101,10 @@
         for item in itemsEvent.items:
             microblog_data = self.host.plugins["XEP-0277"]._item2mbdata(item)
             microblog_data["node"] = itemsEvent.nodeIdentifier
-            microblog_data["groups"] = "\n".join(self._blog_nodes[profile].get(itemsEvent.nodeIdentifier, []))
+            try:
+                microblog_data["groups"] = "\n".join(self._blog_nodes[profile].get(itemsEvent.nodeIdentifier, []))
+            except KeyError:
+                pass 
             self.host.bridge.personalEvent(itemsEvent.sender.full(), "MICROBLOG", microblog_data, profile)
 
     def _getRootNode(self, entity):
@@ -316,7 +319,7 @@
 
     def cleanBlogCollection(self, profile_key='@DEFAULT@'):
         """Remove blog nodes not referenced in config node"""
-        debug(_('Getting mblog nodes'))
+        debug(_('Cleaning mblog nodes'))
         profile = self.host.memory.getProfileName(profile_key)
         if not profile:
             error(_("Unknown profile"))
--- a/src/tools/memory.py	Wed May 11 19:49:55 2011 +0200
+++ b/src/tools/memory.py	Tue May 17 01:34:17 2011 +0200
@@ -25,7 +25,7 @@
 import time
 import cPickle as pickle
 from xml.dom import minidom
-from logging import debug, info, error
+from logging import debug, info, warning, error
 import pdb
 from twisted.internet import defer
 from twisted.words.protocols.jabber import jid