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.
This commit is contained in:
parent
15bf6bc827
commit
4eb2bb7da8
1 changed files with 4 additions and 0 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue