comparison src/browser/sat_browser/blog.py @ 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 a5019e62c3e9
children be2891462e63
comparison
equal deleted inserted replaced
594:a099990f77a6 595:d78126d82ca0
213 else: # allow to create a new comment 213 else: # allow to create a new comment
214 self._parent_entry._current_comment = None 214 self._parent_entry._current_comment = None
215 self.entry_dialog.setWidth('auto') 215 self.entry_dialog.setWidth('auto')
216 try: 216 try:
217 self.toggle_syntax_button.removeFromParent() 217 self.toggle_syntax_button.removeFromParent()
218 except TypeError: 218 except (AttributeError, TypeError):
219 pass 219 pass
220 220
221 def __setBubble(self, edit=False): 221 def __setBubble(self, edit=False):
222 """Set the bubble displaying the initial content.""" 222 """Set the bubble displaying the initial content."""
223 content = {'text': self.content_xhtml if self.content_xhtml else self.content, 223 content = {'text': self.content_xhtml if self.content_xhtml else self.content,
232 else: # assume raw text message have no title 232 else: # assume raw text message have no title
233 self.bubble = base_panels.LightTextEditor(content, self.__modifiedCb, self.__afterEditCb, options={'no_xhtml': True}) 233 self.bubble = base_panels.LightTextEditor(content, self.__modifiedCb, self.__afterEditCb, options={'no_xhtml': True})
234 self.bubble.addStyleName("bubble") 234 self.bubble.addStyleName("bubble")
235 try: 235 try:
236 self.toggle_syntax_button.removeFromParent() 236 self.toggle_syntax_button.removeFromParent()
237 except TypeError: 237 except (AttributeError, TypeError):
238 pass 238 pass
239 self.entry_dialog.add(self.bubble) 239 self.entry_dialog.add(self.bubble)
240 self.edit(edit) 240 self.edit(edit)
241 self.bubble.addEditListener(self.__showWarning) 241 self.bubble.addEditListener(self.__showWarning)
242 242
295 """ 295 """
296 if entry is None: 296 if entry is None:
297 entry = self 297 entry = self
298 try: 298 try:
299 entry.toggle_syntax_button.removeFromParent() 299 entry.toggle_syntax_button.removeFromParent()
300 except TypeError: 300 except (AttributeError, TypeError):
301 pass 301 pass
302 entry.bubble.edit(edit) 302 entry.bubble.edit(edit)
303 if edit: 303 if edit:
304 if isinstance(entry.bubble, richtext.RichTextEditor): 304 if isinstance(entry.bubble, richtext.RichTextEditor):
305 image = '<a class="richTextIcon">A</a>' 305 image = '<a class="richTextIcon">A</a>'
369 self.comments = {} 369 self.comments = {}
370 self.selected_entry = None 370 self.selected_entry = None
371 self.vpanel = VerticalPanel() 371 self.vpanel = VerticalPanel()
372 self.vpanel.setStyleName('microblogPanel') 372 self.vpanel.setStyleName('microblogPanel')
373 self.setWidget(self.vpanel) 373 self.setWidget(self.vpanel)
374
375 def __str__(self):
376 return u"Blog Widget [target: {}, profile: {}]".format(self.target, self.profile)
374 377
375 @property 378 @property
376 def target(self): 379 def target(self):
377 return tuple(self.accepted_groups) 380 return tuple(self.accepted_groups)
378 381
684 self._accepted_groups.extend(groups) 687 self._accepted_groups.extend(groups)
685 except (AttributeError, TypeError): # XXX: should be AttributeError, but pyjamas bugs here 688 except (AttributeError, TypeError): # XXX: should be AttributeError, but pyjamas bugs here
686 self._accepted_groups = groups 689 self._accepted_groups = groups
687 self._accepted_groups.sort() 690 self._accepted_groups.sort()
688 691
689 def isJidAccepted(self, jid_s): 692 def isJidAccepted(self, jid_):
690 """Tell if a jid is actepted and shown in this panel 693 """Tell if a jid is actepted and must be shown in this panel
691 @param jid_s: jid 694
692 @return: True if the jid is accepted""" 695 @param jid_(jid.JID): jid to check
696 @return: True if the jid is accepted
697 """
693 if self.accept_all(): 698 if self.accept_all():
694 return True 699 return True
695 for group in self._accepted_groups: 700 for group in self._accepted_groups:
696 if self.host.contact_panel.isContactInGroup(group, jid_s): 701 if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group):
697 return True 702 return True
698 return False 703 return False