summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-07-25 01:33:17 -0700
committerLance Stout <lancestout@gmail.com>2012-07-25 01:33:17 -0700
commit98b7e8b10ab61af194559bfde0969032b35809c0 (patch)
tree840541e1f20e1593d377ad25f9113f8adfe1fb47 /sleekxmpp
parent9d8de7fc15afc39a666d2ac16b62a068dfc55112 (diff)
downloadslixmpp-98b7e8b10ab61af194559bfde0969032b35809c0.tar.gz
slixmpp-98b7e8b10ab61af194559bfde0969032b35809c0.tar.bz2
slixmpp-98b7e8b10ab61af194559bfde0969032b35809c0.tar.xz
slixmpp-98b7e8b10ab61af194559bfde0969032b35809c0.zip
Fix initializing plugins in stanzas with a language set.
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index 4af441cc..abe0abdc 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -514,8 +514,9 @@ class ElementBase(object):
:param string attrib: The :attr:`plugin_attrib` value of the
plugin to enable.
"""
- if lang is None:
- lang = self.get_lang()
+ default_lang = self.get_lang()
+ if not lang:
+ lang = default_lang
plugin_class = self.plugin_attrib_map[attrib]
@@ -528,7 +529,7 @@ class ElementBase(object):
existing_xml = self.xml.find(plugin_class.tag_name())
if existing_xml is not None:
- if existing_xml.attrib.get('{%s}lang' % XML_NS, '') != lang:
+ if existing_xml.attrib.get('{%s}lang' % XML_NS, default_lang) != lang:
existing_xml = None
plugin = plugin_class(parent=self, xml=existing_xml)
@@ -536,7 +537,8 @@ class ElementBase(object):
if plugin.is_extension:
self.plugins[(attrib, None)] = plugin
else:
- plugin['lang'] = lang
+ if lang != default_lang:
+ plugin['lang'] = lang
self.plugins[(attrib, lang)] = plugin
if plugin_class in self.plugin_iterables:
@@ -576,7 +578,7 @@ class ElementBase(object):
for plugin, stanza in self.plugins.items():
lang = stanza['lang']
if lang:
- values['%s|%s' % (plugin, lang)] = stanza.values
+ values['%s|%s' % (plugin[0], lang)] = stanza.values
else:
values[plugin[0]] = stanza.values
if self.iterables: