Merge branch 'develop' into stream_features

Conflicts:
	sleekxmpp/xmlstream/stanzabase.py
This commit is contained in:
Lance Stout
2011-02-14 16:26:23 -05:00
41 changed files with 2050 additions and 393 deletions

View File

@@ -218,18 +218,6 @@ class ElementBase(object):
xml -- Initialize the stanza with optional existing XML.
parent -- Optional stanza object that contains this stanza.
"""
# To comply with PEP8, method names now use underscores.
# Deprecated method names are re-mapped for backwards compatibility.
self.initPlugin = self.init_plugin
self._getAttr = self._get_attr
self._setAttr = self._set_attr
self._delAttr = self._del_attr
self._getSubText = self._get_sub_text
self._setSubText = self._set_sub_text
self._delSub = self._del_sub
self.getStanzaValues = self._get_stanza_values
self.setStanzaValues = self._set_stanza_values
self.xml = xml
self.plugins = OrderedDict()
self.iterables = []
@@ -1078,17 +1066,6 @@ class StanzaBase(ElementBase):
sfrom -- Optional string or JID object of the sender's JID.
sid -- Optional ID value for the stanza.
"""
# To comply with PEP8, method names now use underscores.
# Deprecated method names are re-mapped for backwards compatibility.
self.setType = self.set_type
self.getTo = self.get_to
self.setTo = self.set_to
self.getFrom = self.get_from
self.setFrom = self.set_from
self.getPayload = self.get_payload
self.setPayload = self.set_payload
self.delPayload = self.del_payload
self.stream = stream
if stream is not None:
self.namespace = stream.default_ns
@@ -1163,12 +1140,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 \
@@ -1177,7 +1159,8 @@ class StanzaBase(ElementBase):
else:
self['to'] = self['from']
del self['from']
self.clear()
if clear:
self.clear()
return self
def error(self):
@@ -1221,3 +1204,25 @@ class StanzaBase(ElementBase):
stanza_ns=self.namespace,
stream=self.stream,
top_level = True)
# To comply with PEP8, method names now use underscores.
# Deprecated method names are re-mapped for backwards compatibility.
ElementBase.initPlugin = ElementBase.init_plugin
ElementBase._getAttr = ElementBase._get_attr
ElementBase._setAttr = ElementBase._set_attr
ElementBase._delAttr = ElementBase._del_attr
ElementBase._getSubText = ElementBase._get_sub_text
ElementBase._setSubText = ElementBase._set_sub_text
ElementBase._delSub = ElementBase._del_sub
ElementBase.getStanzaValues = ElementBase._get_stanza_values
ElementBase.setStanzaValues = ElementBase._set_stanza_values
StanzaBase.setType = StanzaBase.set_type
StanzaBase.getTo = StanzaBase.get_to
StanzaBase.setTo = StanzaBase.set_to
StanzaBase.getFrom = StanzaBase.get_from
StanzaBase.setFrom = StanzaBase.set_from
StanzaBase.getPayload = StanzaBase.get_payload
StanzaBase.setPayload = StanzaBase.set_payload
StanzaBase.delPayload = StanzaBase.del_payload