summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-12-01 18:57:34 +0100
committermathieui <mathieui@mathieui.net>2020-12-02 19:17:33 +0100
commit4eb2bb7da855e67f1fff0d86470cc78c06e64c95 (patch)
tree3cdbdaa3e8d9537d01adfdd9277e5ac209949816
parent15bf6bc827261fa8fa7208da5eb873f5c26f3b6a (diff)
downloadslixmpp-4eb2bb7da855e67f1fff0d86470cc78c06e64c95.tar.gz
slixmpp-4eb2bb7da855e67f1fff0d86470cc78c06e64c95.tar.bz2
slixmpp-4eb2bb7da855e67f1fff0d86470cc78c06e64c95.tar.xz
slixmpp-4eb2bb7da855e67f1fff0d86470cc78c06e64c95.zip
ElementBase: serialize JID objects as strings automatically
This is a shortcut to avoid defining custom methods each time a substanza containing a JID exists in a plugin. Same thing with attributes, there is no place where we do not want this.
-rw-r--r--slixmpp/xmlstream/stanzabase.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/slixmpp/xmlstream/stanzabase.py b/slixmpp/xmlstream/stanzabase.py
index 7eaf78a5..925f2abc 100644
--- a/slixmpp/xmlstream/stanzabase.py
+++ b/slixmpp/xmlstream/stanzabase.py
@@ -745,6 +745,8 @@ class ElementBase(object):
getattr(self, set_method)(value, **kwargs)
else:
if attrib in self.sub_interfaces:
+ if isinstance(value, JID):
+ value = str(value)
if lang == '*':
return self._set_all_sub_text(attrib,
value,
@@ -863,6 +865,8 @@ class ElementBase(object):
if value is None or value == '':
self.__delitem__(name)
else:
+ if isinstance(value, JID):
+ value = str(value)
self.xml.attrib[name] = value
def _del_attr(self, name):