Skip to content
Commits on Source (2)
......@@ -1034,6 +1034,12 @@ class Message(Protocol):
"""
return self.getTagData('thread')
def getOriginID(self):
"""
Return origin-id of the message
"""
return self.getTagAttr('origin-id', namespace=NS_SID, attr='id')
def setBody(self, val):
"""
Set the text of the message"""
......@@ -1071,6 +1077,12 @@ class Message(Protocol):
"""
self.setTagData('thread', val)
def setOriginID(self, val):
"""
Sets the origin-id of the message
"""
self.setTag('origin-id', namespace=NS_SID, attrs={'id': val})
def buildReply(self, text=None):
"""
Builds and returns another message object with specified text. The to,
......
......@@ -331,13 +331,13 @@ class Node(object):
"""
return self.getTags(name, attrs, namespace, one=1)
def getTagAttr(self, tag, attr):
def getTagAttr(self, tag, attr, namespace=None):
"""
Return attribute value of the child with specified name (or None if no
such attribute)
"""
try:
return self.getTag(tag).attrs[attr]
return self.getTag(tag, namespace=namespace).attrs[attr]
except:
return None
......@@ -445,15 +445,15 @@ class Node(object):
else:
return self.addChild(name, attrs, namespace=namespace)
def setTagAttr(self, tag, attr, val):
def setTagAttr(self, tag, attr, val, namespace=None):
"""
Create new node (if not already present) with name "tag" and set it's
attribute "attr" to value "val"
"""
try:
self.getTag(tag).attrs[attr] = val
self.getTag(tag, namespace=namespace).attrs[attr] = val
except Exception:
self.addChild(tag, attrs={attr: val})
self.addChild(tag, namespace=namespace, attrs={attr: val})
def setTagData(self, tag, val, attrs=None):
"""
......