aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/comment.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-11-28 22:07:16 -0500
committerW. Trevor King <wking@drexel.edu>2009-11-28 22:07:16 -0500
commit832843d26eed9023f4cf4fc431527c63ca1d533d (patch)
tree943e1ae77ea78623cdff923f68df9f21155f6bdf /libbe/comment.py
parent7e95956f5088346807a233c63f5bc25436550ef8 (diff)
downloadbugseverywhere-832843d26eed9023f4cf4fc431527c63ca1d533d.tar.gz
Added comment import to Bug.from_xml().
This is a pretty critical feature, dunno how I missed it before. I also added a little check to both Bug and Comment.from_xml() so that xml_string can take an ElementTree Element as well as the usual raw string/unicode. This avoids repeated string <-> Element conversions. Added Bug.add_comment() which handles the addition of a Comment instance, matching .in_reply_to, checking .uuid uniqueness, etc.
Diffstat (limited to 'libbe/comment.py')
-rw-r--r--libbe/comment.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/libbe/comment.py b/libbe/comment.py
index 1adb6f4..e3dfea0 100644
--- a/libbe/comment.py
+++ b/libbe/comment.py
@@ -373,7 +373,10 @@ class Comment(Tree, settings_object.SavedSettingsObject):
"""
if type(xml_string) == types.UnicodeType:
xml_string = xml_string.strip().encode('unicode_escape')
- comment = ElementTree.XML(xml_string)
+ if hasattr(xml_string, 'getchildren'): # already an ElementTree Element
+ comment = xml_string
+ else:
+ comment = ElementTree.XML(xml_string)
if comment.tag != 'comment':
raise utility.InvalidXML( \
'comment', comment, 'root element must be <comment>')