mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
Modified the return values for several methods so that they can be chained.
For example: iq.reply().error().setPayload(something.xml).send()
This commit is contained in:
parent
828cba875f
commit
35f4ef3452
2 changed files with 6 additions and 1 deletions
|
@ -37,6 +37,7 @@ class Iq(RootStanza):
|
||||||
def setPayload(self, value):
|
def setPayload(self, value):
|
||||||
self.clear()
|
self.clear()
|
||||||
StanzaBase.setPayload(self, value)
|
StanzaBase.setPayload(self, value)
|
||||||
|
return self
|
||||||
|
|
||||||
def setQuery(self, value):
|
def setQuery(self, value):
|
||||||
query = self.xml.find("{%s}query" % value)
|
query = self.xml.find("{%s}query" % value)
|
||||||
|
|
|
@ -340,15 +340,18 @@ class StanzaBase(ElementBase):
|
||||||
|
|
||||||
def setPayload(self, value):
|
def setPayload(self, value):
|
||||||
self.xml.append(value)
|
self.xml.append(value)
|
||||||
|
return self
|
||||||
|
|
||||||
def delPayload(self):
|
def delPayload(self):
|
||||||
self.clear()
|
self.clear()
|
||||||
|
return self
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
for child in self.xml.getchildren():
|
for child in self.xml.getchildren():
|
||||||
self.xml.remove(child)
|
self.xml.remove(child)
|
||||||
for plugin in list(self.plugins.keys()):
|
for plugin in list(self.plugins.keys()):
|
||||||
del self.plugins[plugin]
|
del self.plugins[plugin]
|
||||||
|
return self
|
||||||
|
|
||||||
def reply(self):
|
def reply(self):
|
||||||
self['from'], self['to'] = self['to'], self['from']
|
self['from'], self['to'] = self['to'], self['from']
|
||||||
|
@ -357,6 +360,7 @@ class StanzaBase(ElementBase):
|
||||||
|
|
||||||
def error(self):
|
def error(self):
|
||||||
self['type'] = 'error'
|
self['type'] = 'error'
|
||||||
|
return self
|
||||||
|
|
||||||
def getTo(self):
|
def getTo(self):
|
||||||
return JID(self._getAttr('to'))
|
return JID(self._getAttr('to'))
|
||||||
|
|
Loading…
Reference in a new issue