diff options
author | Lance Stout <lancestout@gmail.com> | 2011-03-18 17:39:43 -0400 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-03-18 17:39:43 -0400 |
commit | 566ec8a5f90b8d38d53e3c98212e5a3c6cec6206 (patch) | |
tree | 7794badfafde3962acd4e4bc7161c733d829ada5 /sleekxmpp/xmlstream | |
parent | dca8516cec2d2802930491ea886cd98f81727cbb (diff) | |
parent | dbf6780345bb202d4a0a49034fbfc4535e844170 (diff) | |
download | slixmpp-566ec8a5f90b8d38d53e3c98212e5a3c6cec6206.tar.gz slixmpp-566ec8a5f90b8d38d53e3c98212e5a3c6cec6206.tar.bz2 slixmpp-566ec8a5f90b8d38d53e3c98212e5a3c6cec6206.tar.xz slixmpp-566ec8a5f90b8d38d53e3c98212e5a3c6cec6206.zip |
Merge branch 'develop' into stream_features
Conflicts:
sleekxmpp/xmlstream/stanzabase.py
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r-- | sleekxmpp/xmlstream/stanzabase.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 4f1189fd..8b538d29 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -991,13 +991,18 @@ class ElementBase(object): """ 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. + + 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='', - stanza_ns=self.namespace, - top_level=True) + stanza_ns=stanza_ns, + top_level = not top_level_ns) def __repr__(self): """ @@ -1198,12 +1203,19 @@ class StanzaBase(ElementBase): return self.__class__(xml=copy.deepcopy(self.xml), stream=self.stream) - def __str__(self): - """Serialize the stanza's XML to a string.""" + def __str__(self, top_level_ns=False): + """ + 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='', - stanza_ns=self.namespace, + stanza_ns=stanza_ns, stream=self.stream, - top_level = True) + top_level = not top_level_ns) # To comply with PEP8, method names now use underscores. |