Ticket #21 (closed defect: fixed)

Opened 4 months ago

Last modified 3 months ago

Thread handling

Reported by: guest Assigned to: sylvain
Priority: minor Milestone: headstock-0.3.0
Component: headstock Version: headstock-0.2.0
Keywords: Cc: jason.baker@ttu.edu

Description

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)

Change History

08/11/08 14:59:01 changed by sylvain

  • priority changed from major to minor.
  • component changed from amplee to headstock.

08/12/08 02:37:10 changed by sylvain

  • status changed from new to closed.
  • version changed from Current to headstock-0.2.0.
  • resolution set to fixed.
  • milestone changed from headstock-0.1.0 to headstock-0.3.0.

Fixed in 766

I did not implemente Message.str as I don't believe it's right to start returning xml that way. I would have to propagate that APi change through every object. I don't think it's okay.