Fix broken handling of non-text/plain comments
authorW. Trevor King <wking@drexel.edu>
Sat, 23 Jan 2010 21:44:55 +0000 (16:44 -0500)
committerW. Trevor King <wking@drexel.edu>
Sat, 23 Jan 2010 21:44:55 +0000 (16:44 -0500)
libbe/command/comment.py
libbe/comment.py

index b82576a9f0ec37dba222ca1f157d28ba2dc01c34..cb463980131288bbe3d37d12dad9750c6db1a9d9 100644 (file)
@@ -150,7 +150,7 @@ class Comment (libbe.command.Command):
         new = parent.new_reply(body=body)
         for key in ['alt-id', 'author', 'content-type']:
             if params[key] != None:
-                setattr(new, key, params[key])
+                setattr(new, new._setting_name_to_attr_name(key), params[key])
         print >> self.stdout, 'Created comment with ID %s' % new.id.user()
         return 0
 
index accd4df28c2bc93ce03dc3d7ca008421bb3e9abb..21118f0a10b297ff7fb35ade88b919eb39f53498 100644 (file)
@@ -26,6 +26,13 @@ import os.path
 import sys
 import time
 import types
+try:
+    from email.mime.base import MIMEBase
+    from email.encoders import encode_base64
+except ImportError:
+    # adjust to old python 2.4
+    from email.MIMEBase import MIMEBase
+    from email.Encoders import encode_base64
 try: # import core module, Python >= 2.5
     from xml.etree import ElementTree
 except ImportError: # look for non-core module
@@ -289,9 +296,9 @@ class Comment (Tree, settings_object.SavedSettingsObject):
             body = (self.body or '').rstrip('\n')
         else:
             maintype,subtype = self.content_type.split('/',1)
-            msg = email.mime.base.MIMEBase(maintype, subtype)
+            msg = MIMEBase(maintype, subtype)
             msg.set_payload(self.body or '')
-            email.encoders.encode_base64(msg)
+            encode_base64(msg)
             body = base64.encodestring(self.body or '')
         info = [('uuid', self.uuid),
                 ('alt-id', self.alt_id),