summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/stanzabase.py
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/xmlstream/stanzabase.py')
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py14
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):