changeset 595:d78126d82ca0 frontends_multi_profiles

browser side (blog module): fixed isJidAccepted + added __str__ method to facilitate debugging + use of AttributeError and TypeError in some exception (because pyjamas can raise both depending on compilation options)
author Goffi <goffi@goffi.org>
date Fri, 06 Feb 2015 19:15:52 +0100
parents a099990f77a6
children 9054793ab60d
files src/browser/sat_browser/blog.py
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/sat_browser/blog.py	Fri Feb 06 19:11:02 2015 +0100
+++ b/src/browser/sat_browser/blog.py	Fri Feb 06 19:15:52 2015 +0100
@@ -215,7 +215,7 @@
         self.entry_dialog.setWidth('auto')
         try:
             self.toggle_syntax_button.removeFromParent()
-        except TypeError:
+        except (AttributeError, TypeError):
             pass
 
     def __setBubble(self, edit=False):
@@ -234,7 +234,7 @@
         self.bubble.addStyleName("bubble")
         try:
             self.toggle_syntax_button.removeFromParent()
-        except TypeError:
+        except (AttributeError, TypeError):
             pass
         self.entry_dialog.add(self.bubble)
         self.edit(edit)
@@ -297,7 +297,7 @@
             entry = self
         try:
             entry.toggle_syntax_button.removeFromParent()
-        except TypeError:
+        except (AttributeError, TypeError):
             pass
         entry.bubble.edit(edit)
         if edit:
@@ -372,6 +372,9 @@
         self.vpanel.setStyleName('microblogPanel')
         self.setWidget(self.vpanel)
 
+    def __str__(self):
+        return u"Blog Widget [target: {}, profile: {}]".format(self.target, self.profile)
+
     @property
     def target(self):
         return tuple(self.accepted_groups)
@@ -686,13 +689,15 @@
             self._accepted_groups = groups
         self._accepted_groups.sort()
 
-    def isJidAccepted(self, jid_s):
-        """Tell if a jid is actepted and shown in this panel
-        @param jid_s: jid
-        @return: True if the jid is accepted"""
+    def isJidAccepted(self, jid_):
+        """Tell if a jid is actepted and must be shown in this panel
+
+        @param jid_(jid.JID): jid to check
+        @return: True if the jid is accepted
+        """
         if self.accept_all():
             return True
         for group in self._accepted_groups:
-            if self.host.contact_panel.isContactInGroup(group, jid_s):
+            if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group):
                 return True
         return False