summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-08-26 18:40:58 -0400
committerLance Stout <lancestout@gmail.com>2010-08-26 18:40:58 -0400
commitca6ce26b0dd4975d3f5e0b5209a6a66a7dadbed5 (patch)
tree01720ff6b7d4a08454e587987db7a317a0d2f93f
parent37ff17b0cbefd8a0056b131621728123b292e211 (diff)
downloadslixmpp-ca6ce26b0dd4975d3f5e0b5209a6a66a7dadbed5.tar.gz
slixmpp-ca6ce26b0dd4975d3f5e0b5209a6a66a7dadbed5.tar.bz2
slixmpp-ca6ce26b0dd4975d3f5e0b5209a6a66a7dadbed5.tar.xz
slixmpp-ca6ce26b0dd4975d3f5e0b5209a6a66a7dadbed5.zip
Added comments to _fix_ns to clarify the cleaning procedure.
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index 8814df78..9785da0b 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -765,17 +765,24 @@ class ElementBase(object):
False, which returns a flat string path.
"""
fixed = []
+ # Split the XPath into a series of blocks, where a block
+ # is started by an element with a namespace.
ns_blocks = xpath.split('{')
for ns_block in ns_blocks:
if '}' in ns_block:
+ # Apply the found namespace to following elements
+ # that do not have namespaces.
namespace = ns_block.split('}')[0]
elements = ns_block.split('}')[1].split('/')
else:
+ # Apply the stanza's namespace to the following
+ # elements since no namespace was provided.
namespace = self.namespace
elements = ns_block.split('/')
for element in elements:
if element:
+ # Skip empty entry artifacts from splitting.
fixed.append('{%s}%s' % (namespace,
element))
if split: