diff options
author | Tom Nichols <tmnichols@gmail.com> | 2010-06-02 15:45:51 -0400 |
---|---|---|
committer | Tom Nichols <tmnichols@gmail.com> | 2010-06-02 15:45:51 -0400 |
commit | 77bff9cce7deff133017c3aa2c36ff121adfd544 (patch) | |
tree | 4eed9803932e32dd6e691b9dc2c6dc8b081dbb01 /sleekxmpp/xmlstream/stanzabase.py | |
parent | 3f41fdd231998aeb68a7490f723d3c092bd7e380 (diff) | |
parent | 7930ed22f2371ba3405f9644f427bec9554d2a15 (diff) | |
download | slixmpp-77bff9cce7deff133017c3aa2c36ff121adfd544.tar.gz slixmpp-77bff9cce7deff133017c3aa2c36ff121adfd544.tar.bz2 slixmpp-77bff9cce7deff133017c3aa2c36ff121adfd544.tar.xz slixmpp-77bff9cce7deff133017c3aa2c36ff121adfd544.zip |
Merge branch 'hacks' of git@github.com:tomstrummer/SleekXMPP into hacks
Diffstat (limited to 'sleekxmpp/xmlstream/stanzabase.py')
-rw-r--r-- | sleekxmpp/xmlstream/stanzabase.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 018e81c3..64020c8f 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -78,6 +78,9 @@ class ElementBase(tostring.ToString): def __iter__(self): self.idx = 0 return self + + def __bool__(self): + return True def __next__(self): self.idx += 1 @@ -319,6 +322,8 @@ class StanzaBase(ElementBase): def __init__(self, stream=None, xml=None, stype=None, sto=None, sfrom=None, sid=None): self.stream = stream + if stream is not None: + self.namespace = stream.default_ns ElementBase.__init__(self, xml) if stype is not None: self['type'] = stype @@ -326,13 +331,11 @@ class StanzaBase(ElementBase): self['to'] = sto if sfrom is not None: self['from'] = sfrom - if stream is not None: - self.namespace = stream.default_ns self.tag = "{%s}%s" % (self.namespace, self.name) def setType(self, value): if value in self.types: - self.xml.attrib['type'] = value + self.xml.attrib['type'] = value return self def getPayload(self): @@ -340,15 +343,18 @@ class StanzaBase(ElementBase): def setPayload(self, value): self.xml.append(value) + return self def delPayload(self): self.clear() + return self def clear(self): for child in self.xml.getchildren(): self.xml.remove(child) for plugin in list(self.plugins.keys()): del self.plugins[plugin] + return self def reply(self): self['from'], self['to'] = self['to'], self['from'] @@ -357,6 +363,7 @@ class StanzaBase(ElementBase): def error(self): self['type'] = 'error' + return self def getTo(self): return JID(self._getAttr('to')) |