From bd9bf3f1c7c17606f455ce0cf9c4d0b6b237a7fe Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 27 Jan 2011 18:05:05 -0500 Subject: Update tostring methods. Will now always show top-level namespace, unless it is the same as the stream's default namespace. Also added the XMPP stream namespace to the namespace map as 'stream'. --- sleekxmpp/xmlstream/stanzabase.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 3937a7a9..83d86999 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -1007,7 +1007,9 @@ class ElementBase(object): """ Return a string serialization of the underlying XML object. """ - return tostring(self.xml, xmlns='', stanza_ns=self.namespace) + return tostring(self.xml, xmlns='', + stanza_ns=self.namespace, + top_level=True) def __repr__(self): """ @@ -1217,4 +1219,5 @@ class StanzaBase(ElementBase): """Serialize the stanza's XML to a string.""" return tostring(self.xml, xmlns='', stanza_ns=self.namespace, - stream=self.stream) + stream=self.stream, + top_level = True) -- cgit v1.2.3 From 47bc50d9fbbe8d72b589a6360aa8b5f32d6ba74b Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 4 Aug 2011 22:37:22 -0700 Subject: Cosmetic PEP8 fixes. --- sleekxmpp/xmlstream/stanzabase.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index f1a9e1f5..a2826ead 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -482,7 +482,8 @@ class ElementBase(object): if plugin: if plugin not in self.plugins: self.init_plugin(plugin) - handler = getattr(self.plugins[plugin], set_method, None) + handler = getattr(self.plugins[plugin], + set_method, None) if handler: return handler(value) @@ -1066,7 +1067,7 @@ class ElementBase(object): 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=not top_level_ns) def __repr__(self): """ @@ -1285,7 +1286,7 @@ class StanzaBase(ElementBase): return tostring(self.xml, xmlns='', stanza_ns=stanza_ns, stream=self.stream, - top_level = not top_level_ns) + top_level=not top_level_ns) # To comply with PEP8, method names now use underscores. -- cgit v1.2.3