Merge branch 'develop' into stream_features

Conflicts:
	sleekxmpp/xmlstream/stanzabase.py
This commit is contained in:
Lance Stout 2011-03-18 17:39:43 -04:00
commit 566ec8a5f9
2 changed files with 20 additions and 8 deletions

View file

@ -42,7 +42,7 @@ class xep_0092(base_plugin):
self.xmpp.register_handler( self.xmpp.register_handler(
Callback('Software Version', Callback('Software Version',
StanzaPath('iq@=get/software_version'), StanzaPath('iq@type=get/software_version'),
self._handle_version)) self._handle_version))
register_stanza_plugin(Iq, Version) register_stanza_plugin(Iq, Version)

View file

@ -991,13 +991,18 @@ class ElementBase(object):
""" """
return self.__class__(xml=copy.deepcopy(self.xml), parent=self.parent) return self.__class__(xml=copy.deepcopy(self.xml), parent=self.parent)
def __str__(self): def __str__(self, top_level_ns=True):
""" """
Return a string serialization of the underlying XML object. Return a string serialization of the underlying XML object.
Arguments:
top_level_ns -- Display the top-most namespace.
Defaults to True.
""" """
stanza_ns = '' if top_level_ns else self.namespace
return tostring(self.xml, xmlns='', return tostring(self.xml, xmlns='',
stanza_ns=self.namespace, stanza_ns=stanza_ns,
top_level=True) top_level = not top_level_ns)
def __repr__(self): def __repr__(self):
""" """
@ -1198,12 +1203,19 @@ class StanzaBase(ElementBase):
return self.__class__(xml=copy.deepcopy(self.xml), return self.__class__(xml=copy.deepcopy(self.xml),
stream=self.stream) stream=self.stream)
def __str__(self): def __str__(self, top_level_ns=False):
"""Serialize the stanza's XML to a string.""" """
Serialize the stanza's XML to a string.
Arguments:
top_level_ns -- Display the top-most namespace.
Defaults to False.
"""
stanza_ns = '' if top_level_ns else self.namespace
return tostring(self.xml, xmlns='', return tostring(self.xml, xmlns='',
stanza_ns=self.namespace, stanza_ns=stanza_ns,
stream=self.stream, stream=self.stream,
top_level = True) top_level = not top_level_ns)
# To comply with PEP8, method names now use underscores. # To comply with PEP8, method names now use underscores.