From 79f3c1ac8f1aa0b099958e824dc53c17daf9849f Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Sun, 17 Aug 2014 23:12:46 +0200 Subject: serialize JID to allow json serializing --- sleekxmpp/xmlstream/stanzabase.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 97107098..c6ed4163 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -565,7 +565,10 @@ class ElementBase(object): values = {} values['lang'] = self['lang'] for interface in self.interfaces: - values[interface] = self[interface] + if isinstance(self[interface], JID): + values[interface] = self[interface].jid + else: + values[interface] = self[interface] if interface in self.lang_interfaces: values['%s|*' % interface] = self['%s|*' % interface] for plugin, stanza in self.plugins.items(): -- cgit v1.2.3 From aabec8b993748866b9cf3f09ebb7ae7ce2ddc426 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 21 Aug 2014 10:05:42 -0700 Subject: Fix some more Unicode in **kwargs issues in Py2.6 --- sleekxmpp/xmlstream/stanzabase.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index c6ed4163..11c8dd67 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -19,6 +19,7 @@ import logging import weakref from xml.etree import cElementTree as ET +from sleekxmpp.util import safedict from sleekxmpp.xmlstream import JID from sleekxmpp.xmlstream.tostring import tostring from sleekxmpp.thirdparty import OrderedDict @@ -679,6 +680,8 @@ class ElementBase(object): if lang and attrib in self.lang_interfaces: kwargs['lang'] = lang + kwargs = safedict(kwargs) + if attrib == 'substanzas': return self.iterables elif attrib in self.interfaces or attrib == 'lang': @@ -755,6 +758,8 @@ class ElementBase(object): if lang and attrib in self.lang_interfaces: kwargs['lang'] = lang + kwargs = safedict(kwargs) + if attrib in self.interfaces or attrib == 'lang': if value is not None: set_method = "set_%s" % attrib.lower() @@ -841,6 +846,8 @@ class ElementBase(object): if lang and attrib in self.lang_interfaces: kwargs['lang'] = lang + kwargs = safedict(kwargs) + if attrib in self.interfaces or attrib == 'lang': del_method = "del_%s" % attrib.lower() del_method2 = "del%s" % attrib.title() -- cgit v1.2.3 From 0b14ef82d4058925e7e9db22038777d4654e8199 Mon Sep 17 00:00:00 2001 From: Robert Robinson Date: Tue, 15 Sep 2015 10:05:53 -0600 Subject: Add test case for reported and items Previous stanza test cases didn't have test cases for reported and item field types in forms. This fixes that issue. Modified stanzabase to use an ordered dict so that can guarentee the that 'items' in a form are added after reported. Also updated the set of interfaces that are stored in Form to be a ordered set. Used the order set implementation from: https://code.activestate.com/recipes/576694/ The OrderedSet implementation is licensed under the MIT license and is developed by the same developer of the ordereddict. --- sleekxmpp/xmlstream/stanzabase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 11c8dd67..c2e0f718 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -563,7 +563,7 @@ class ElementBase(object): .. versionadded:: 1.0-Beta1 """ - values = {} + values = OrderedDict() values['lang'] = self['lang'] for interface in self.interfaces: if isinstance(self[interface], JID): -- cgit v1.2.3