summaryrefslogtreecommitdiff
path: root/slixmpp/stanza/rootstanza.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2015-02-12 12:17:01 +0100
committermathieui <mathieui@mathieui.net>2015-02-12 12:17:01 +0100
commitf6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81 (patch)
treeaa566e12ee940d2df17541d5aa53ec38aba162fc /slixmpp/stanza/rootstanza.py
parent8b36e918e897a55622c279507a7bc886fdfb1081 (diff)
downloadslixmpp-f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81.tar.gz
slixmpp-f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81.tar.bz2
slixmpp-f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81.tar.xz
slixmpp-f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81.zip
Fix the uses of stanza.reply()
This is relying on the stanzas being copied for each handler. We no longer do that for performance reasons, so instead of editing the copy in-place, stanza.reply() now returns a new stanza.
Diffstat (limited to 'slixmpp/stanza/rootstanza.py')
-rw-r--r--slixmpp/stanza/rootstanza.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/slixmpp/stanza/rootstanza.py b/slixmpp/stanza/rootstanza.py
index 7bd0c32d..ff139382 100644
--- a/slixmpp/stanza/rootstanza.py
+++ b/slixmpp/stanza/rootstanza.py
@@ -46,37 +46,37 @@ class RootStanza(StanzaBase):
# locally. Using the condition/text from that error
# response could leak too much information, so we'll
# only use a generic error here.
- self.reply()
- self['error']['condition'] = 'undefined-condition'
- self['error']['text'] = 'External error'
- self['error']['type'] = 'cancel'
+ reply = self.reply()
+ reply['error']['condition'] = 'undefined-condition'
+ reply['error']['text'] = 'External error'
+ reply['error']['type'] = 'cancel'
log.warning('You should catch IqError exceptions')
- self.send()
+ reply.send()
elif isinstance(e, IqTimeout):
- self.reply()
- self['error']['condition'] = 'remote-server-timeout'
- self['error']['type'] = 'wait'
+ reply = self.reply()
+ reply['error']['condition'] = 'remote-server-timeout'
+ reply['error']['type'] = 'wait'
log.warning('You should catch IqTimeout exceptions')
- self.send()
+ reply.send()
elif isinstance(e, XMPPError):
# We raised this deliberately
- self.reply(clear=e.clear)
- self['error']['condition'] = e.condition
- self['error']['text'] = e.text
- self['error']['type'] = e.etype
+ reply = self.reply(clear=e.clear)
+ reply['error']['condition'] = e.condition
+ reply['error']['text'] = e.text
+ reply['error']['type'] = e.etype
if e.extension is not None:
# Extended error tag
extxml = ET.Element("{%s}%s" % (e.extension_ns, e.extension),
e.extension_args)
- self['error'].append(extxml)
- self.send()
+ reply['error'].append(extxml)
+ reply.send()
else:
# We probably didn't raise this on purpose, so send an error stanza
- self.reply()
- self['error']['condition'] = 'undefined-condition'
- self['error']['text'] = "Slixmpp got into trouble."
- self['error']['type'] = 'cancel'
- self.send()
+ reply = self.reply()
+ reply['error']['condition'] = 'undefined-condition'
+ reply['error']['text'] = "Slixmpp got into trouble."
+ reply['error']['type'] = 'cancel'
+ reply.send()
# log the error
log.exception('Error handling {%s}%s stanza',
self.namespace, self.name)