Add initial support for xml:lang for streams and stanza plugins.

Remaining items are suitable default actions for language supporting
interfaces.
This commit is contained in:
Lance Stout
2012-06-05 16:54:26 -07:00
parent ee702f4071
commit 181aea737d
10 changed files with 243 additions and 89 deletions

View File

@@ -223,6 +223,9 @@ class XMLStream(object):
#: stream wrapper itself.
self.default_ns = ''
self.default_lang = None
self.peer_default_lang = None
#: The namespace of the enveloping stream element.
self.stream_ns = ''
@@ -1431,6 +1434,10 @@ class XMLStream(object):
if depth == 0:
# We have received the start of the root element.
root = xml
log.debug('RECV: %s', tostring(root, xmlns=self.default_ns,
stream=self,
top_level=True,
open_only=True))
# Perform any stream initialization actions, such
# as handshakes.
self.stream_end_event.clear()
@@ -1478,6 +1485,8 @@ class XMLStream(object):
stanza_type = stanza_class
break
stanza = stanza_type(self, xml)
if stanza['lang'] is None and self.peer_default_lang:
stanza['lang'] = self.peer_default_lang
return stanza
def __spawn_event(self, xml):