summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-08-13 10:26:33 -0400
committerLance Stout <lancestout@gmail.com>2010-08-13 10:26:33 -0400
commit415520200efbc6f8a93d1e667f2b7d43b7994667 (patch)
tree089cb4f1f742c55b369c00ed6f1d6b405c93446f
parent747001d33c87dbd644b369f9e41da9ba16927561 (diff)
downloadslixmpp-415520200efbc6f8a93d1e667f2b7d43b7994667.tar.gz
slixmpp-415520200efbc6f8a93d1e667f2b7d43b7994667.tar.bz2
slixmpp-415520200efbc6f8a93d1e667f2b7d43b7994667.tar.xz
slixmpp-415520200efbc6f8a93d1e667f2b7d43b7994667.zip
Updated ElementBase.__init__
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py48
1 files changed, 30 insertions, 18 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index a6425b80..6762792f 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -45,24 +45,36 @@ class ElementBase(object):
subitem = None
def __init__(self, xml=None, parent=None):
- if parent is None:
- self.parent = None
- else:
- self.parent = weakref.ref(parent)
- self.xml = xml
- self.plugins = {}
- self.iterables = []
- self.idx = 0
- if not self.setup(xml):
- 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:
- for sub in self.subitem:
- if child.tag == "{%s}%s" % (sub.namespace, sub.name):
- self.iterables.append(sub(xml=child, parent=self))
- break
-
+ """
+ Create a new stanza object.
+
+ Arguments:
+ xml -- Initialize the stanza with optional existing XML.
+ parent -- Optional stanza object that contains this stanza.
+ """
+ self.xml = xml
+ self.plugins = {}
+ self.iterables = []
+ self.idx = 0
+ if parent is None:
+ self.parent = None
+ else:
+ self.parent = weakref.ref(parent)
+
+ if self.setup(xml):
+ # If we generated our own XML, then everything is ready.
+ return
+
+ # Initialize values using provided XML
+ for child in self.xml.getchildren():
+ if child.tag in self.plugin_tag_map:
+ plugin = self.plugin_tag_map[child.tag]
+ self.plugins[plugin.plugin_attrib] = plugin(child, 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(child, self))
+ break
@property
def attrib(self): #backwards compatibility