diff options
author | Lance Stout <lancestout@gmail.com> | 2011-02-11 15:20:26 -0500 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-02-11 15:20:26 -0500 |
commit | 0d326383799a7d7bb69fec9dcd1eaf9e1a64eab8 (patch) | |
tree | 20bf5d0037cdd33bf45460c7001dd593643293b0 /sleekxmpp/xmlstream | |
parent | c4b1212c44e0758c6361ca46c6c3a90e27ac876f (diff) | |
download | slixmpp-0d326383799a7d7bb69fec9dcd1eaf9e1a64eab8.tar.gz slixmpp-0d326383799a7d7bb69fec9dcd1eaf9e1a64eab8.tar.bz2 slixmpp-0d326383799a7d7bb69fec9dcd1eaf9e1a64eab8.tar.xz slixmpp-0d326383799a7d7bb69fec9dcd1eaf9e1a64eab8.zip |
XMPPError exceptions can keep a stanza's contents.
This allows exceptions to include the original
content of a stanza in the error response by including
the parameter clear=False when raising the exception.
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r-- | sleekxmpp/xmlstream/stanzabase.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 3937a7a9..1f229cea 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -1161,12 +1161,17 @@ class StanzaBase(ElementBase): self.clear() return self - def reply(self): + def reply(self, clear=True): """ - Reset the stanza and swap its 'from' and 'to' attributes to prepare - for sending a reply stanza. + Swap the 'from' and 'to' attributes to prepare the stanza for + sending a reply. If clear=True, then also remove the stanza's + contents to make room for the reply content. For client streams, the 'from' attribute is removed. + + Arguments: + clear -- Indicates if the stanza's contents should be + removed. Defaults to True """ # if it's a component, use from if self.stream and hasattr(self.stream, "is_component") and \ @@ -1175,7 +1180,8 @@ class StanzaBase(ElementBase): else: self['to'] = self['from'] del self['from'] - self.clear() + if clear: + self.clear() return self def error(self): |