I'm putting this down as a defect because it DOES fix a bug (albeit a relatively simple one). But primarily, this is an enhancement to the way headstock handles threads in IM messages. The bugfix is actually in the last change. The to_element method will currently put the thread object in the element instead of converting it to unicode.
Index: headstock/api/im.py
===================================================================
--- headstock/api/im.py (revision 745)
+++ headstock/api/im.py (working copy)
@@ -45,6 +45,12 @@
def __init__(self, text):
self.text = text
+ def __str__(self):
+ return str(self.text)
+
+ def __unicode__(self):
+ return unicode(self.text)
+
def __repr__(self):
return '<Thread at %s>' % (hex(id(self)),)
@@ -65,7 +71,9 @@
self.foreign = []
self.thread = None
self.timestamp = datetime.now()
-
+ def __str__(self):
+ return Message.to_element(self).xml()
+
def __repr__(self):
return '<Message (%s) at %s>' % (self.stanza_id, hex(id(self)),)
@@ -152,7 +160,7 @@
b.xml_children.append(body.inner)
if m.thread:
- E(u'thread', content=m.thread,
+ E(u'thread', content=unicode(m.thread),
namespace=XMPP_CLIENT_NS, parent=e)
x = E(u'x', namespace=XMPP_EVENT_NS, parent=e)