quick frontend(chat): display a useful message with __unicode__ and __str__
This commit is contained in:
parent
465d9ad62e
commit
3830c1c176
1 changed files with 11 additions and 1 deletions
|
|
@ -85,6 +85,16 @@ class Message(object):
|
|||
self.handleMe()
|
||||
self.widgets = set() # widgets linked to this message
|
||||
|
||||
def __unicode__(self):
|
||||
return u"Message<{mess_type}> [{time}]{nick}> {message}".format(
|
||||
mess_type=self.type,
|
||||
time=self.time_text,
|
||||
nick=self.nick,
|
||||
message=self.main_message)
|
||||
|
||||
def __str__(self):
|
||||
return self.__unicode__().encode('utf-8', 'ignore')
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
return self.parent.host
|
||||
|
|
@ -328,7 +338,7 @@ class QuickChat(quick_widgets.QuickWidget):
|
|||
|
||||
## Widget management ##
|
||||
|
||||
def __str__(self):
|
||||
def __unicode__(self):
|
||||
return u"Chat Widget [target: {}, type: {}, profile: {}]".format(
|
||||
self.target, self.type, self.profile
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue