Pass content_type to Comment.new_reply() to fix error adding non-text/ comments
authorW. Trevor King <wking@drexel.edu>
Tue, 20 Oct 2009 13:30:42 +0000 (09:30 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 20 Oct 2009 13:30:42 +0000 (09:30 -0400)
becommands/comment.py
libbe/comment.py

index 9a614b26916ae6e412bbebb852ab20fc473103eb..950a95a6ba7f967dbe73fdee8e5ef1f1daa56cf0 100644 (file)
@@ -119,13 +119,11 @@ def execute(args, manipulate_encodings=True):
             body+='\n'
 
     if options.XML == False:
-        new = parent.new_reply(body=body)
+        new = parent.new_reply(body=body, content_type=options.content_type)
         if options.author != None:
             new.author = options.author
         if options.alt_id != None:
             new.alt_id = options.alt_id
-        if options.content_type != None:
-            new.content_type = options.content_type
     else: # import XML comment [list]
         # read in the comments
         str_body = body.encode("unicode_escape").replace(r'\n', '\n')
index 41bc7e6c1ea629277e8836186ad570ab676ea22a..02bcc9353f73cb3511f4fd034daad09eb8a94b54 100644 (file)
@@ -604,7 +604,7 @@ class Comment(Tree, settings_object.SavedSettingsObject):
             reply.in_reply_to = self.uuid
         self.append(reply)
 
-    def new_reply(self, body=None):
+    def new_reply(self, body=None, content_type=None):
         """
         >>> comm = Comment(bug=None, body="Some insightful remarks")
         >>> repA = comm.new_reply("Critique original comment")
@@ -613,6 +613,8 @@ class Comment(Tree, settings_object.SavedSettingsObject):
         True
         """
         reply = Comment(self.bug, body=body)
+        if content_type != None: # set before saving body to decide binary format
+            reply.content_type = content_type
         if self.bug != None:
             reply.set_sync_with_disk(self.bug.sync_with_disk)
         if reply.sync_with_disk == True: