summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/stanzabase.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-09-24 20:59:51 -0700
committerLance Stout <lancestout@gmail.com>2012-09-24 20:59:51 -0700
commit6c57bb055346384760129c25ad5402913982eaac (patch)
treef89eea2ee3836a64ee893bcd269d8f008e9158e6 /sleekxmpp/xmlstream/stanzabase.py
parentc2ae1ee8910a60902ec4aa709ef7c26376eede47 (diff)
downloadslixmpp-6c57bb055346384760129c25ad5402913982eaac.tar.gz
slixmpp-6c57bb055346384760129c25ad5402913982eaac.tar.bz2
slixmpp-6c57bb055346384760129c25ad5402913982eaac.tar.xz
slixmpp-6c57bb055346384760129c25ad5402913982eaac.zip
Simplify stringifying XML
Diffstat (limited to 'sleekxmpp/xmlstream/stanzabase.py')
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index abe0abdc..233e91f6 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -1400,10 +1400,8 @@ class ElementBase(object):
:param bool 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=stanza_ns,
- top_level=not top_level_ns)
+ top_level=True)
def __repr__(self):
"""Use the stanza's serialized XML as its representation."""
@@ -1592,11 +1590,10 @@ class StanzaBase(ElementBase):
:param bool 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=stanza_ns,
+ xmlns = self.stream.default_ns if self.stream else ''
+ return tostring(self.xml, xmlns=xmlns,
stream=self.stream,
- top_level=not top_level_ns)
+ top_level=(self.stream is None))
#: A JSON/dictionary version of the XML content exposed through