diff options
author | Nathan Fritz <nathan@andyet.net> | 2010-04-21 23:51:37 -0700 |
---|---|---|
committer | Nathan Fritz <nathan@andyet.net> | 2010-04-21 23:51:37 -0700 |
commit | 37b571c55ab00b3107a480027f0ba212831bf7ed (patch) | |
tree | aff996e605be2e4473acc6ac19373e07017501ac /sleekxmpp/xmlstream | |
parent | 2a30e3fe0c397bc1111449c2980e77e67d9114c1 (diff) | |
download | slixmpp-37b571c55ab00b3107a480027f0ba212831bf7ed.tar.gz slixmpp-37b571c55ab00b3107a480027f0ba212831bf7ed.tar.bz2 slixmpp-37b571c55ab00b3107a480027f0ba212831bf7ed.tar.xz slixmpp-37b571c55ab00b3107a480027f0ba212831bf7ed.zip |
added pubsub#event stanzas, multi-subtypes iterable stanzas, pubsub#event test coverage
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r-- | sleekxmpp/xmlstream/stanzabase.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index f72aa6e2..ae9e9df7 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -60,8 +60,11 @@ class ElementBase(tostring.ToString): for child in self.xml.getchildren(): if child.tag in self.plugin_tag_map: self.plugins[self.plugin_tag_map[child.tag].plugin_attrib] = self.plugin_tag_map[child.tag](xml=child, parent=self) - if self.subitem is not None and child.tag == "{%s}%s" % (self.subitem.namespace, self.subitem.name): - self.iterables.append(self.subitem(xml=child, parent=self)) + if self.subitem is not None: + for sub in self.subitem: + if child.tag == "{%s}%s" % (sub.namespace, sub.name): + self.iterables.append(sub(xml=child, parent=self)) + break @property @@ -263,7 +266,10 @@ class ElementBase(tostring.ToString): for pluginkey in self.plugins: out[pluginkey] = self.plugins[pluginkey].getValues() if self.iterables: - iterables = [x.getValues() for x in self.iterables] + iterables = [] + for stanza in self.iterables: + iterables.append(stanza.getValues()) + iterables[-1].update({'__childtag__': "{%s}%s" % (stanza.namespace, stanza.name)}) out['substanzas'] = iterables return out @@ -271,9 +277,13 @@ class ElementBase(tostring.ToString): for interface in attrib: if interface == 'substanzas': for subdict in attrib['substanzas']: - sub = self.subitem(parent=self) - sub.setValues(subdict) - self.iterables.append(sub) + if '__childtag__' in subdict: + for subclass in self.subitem: + if subdict['__childtag__'] == "{%s}%s" % (subclass.namespace, subclass.name): + sub = subclass(parent=self) + sub.setValues(subdict) + self.iterables.append(sub) + break elif interface in self.interfaces: self[interface] = attrib[interface] elif interface in self.plugin_attrib_map and interface not in self.plugins: |