summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-05-22 22:40:30 +0800
committerNathan Fritz <fritzy@netflint.net>2010-05-25 07:28:43 +0800
commit35f4ef3452015d7f9ef1e300bc104793de12f1e8 (patch)
treeab75df6f8274020e73fdf809c691d54deff984a9 /sleekxmpp
parent828cba875fa5466493e3ea3f804bb349743a0615 (diff)
downloadslixmpp-35f4ef3452015d7f9ef1e300bc104793de12f1e8.tar.gz
slixmpp-35f4ef3452015d7f9ef1e300bc104793de12f1e8.tar.bz2
slixmpp-35f4ef3452015d7f9ef1e300bc104793de12f1e8.tar.xz
slixmpp-35f4ef3452015d7f9ef1e300bc104793de12f1e8.zip
Modified the return values for several methods so that they can be chained.
For example: iq.reply().error().setPayload(something.xml).send()
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/stanza/iq.py1
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/sleekxmpp/stanza/iq.py b/sleekxmpp/stanza/iq.py
index 4969b703..ded7515f 100644
--- a/sleekxmpp/stanza/iq.py
+++ b/sleekxmpp/stanza/iq.py
@@ -37,6 +37,7 @@ class Iq(RootStanza):
def setPayload(self, value):
self.clear()
StanzaBase.setPayload(self, value)
+ return self
def setQuery(self, value):
query = self.xml.find("{%s}query" % value)
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index 018e81c3..3f3f5e08 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -332,7 +332,7 @@ class StanzaBase(ElementBase):
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 +340,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 +360,7 @@ class StanzaBase(ElementBase):
def error(self):
self['type'] = 'error'
+ return self
def getTo(self):
return JID(self._getAttr('to'))