From 8da387a38aa90069cdcb44df2a36ccea303b62c8 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sat, 16 Jun 2012 14:12:13 -0700 Subject: Add support for error conditions that include data. --- sleekxmpp/stanza/stream_error.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/stanza/stream_error.py') diff --git a/sleekxmpp/stanza/stream_error.py b/sleekxmpp/stanza/stream_error.py index 5a6dac96..bf77d932 100644 --- a/sleekxmpp/stanza/stream_error.py +++ b/sleekxmpp/stanza/stream_error.py @@ -54,7 +54,7 @@ class StreamError(Error, StanzaBase): """ namespace = 'http://etherx.jabber.org/streams' - interfaces = set(('condition', 'text')) + interfaces = set(('condition', 'text', 'see_other_host')) conditions = set(( 'bad-format', 'bad-namespace-prefix', 'conflict', 'connection-timeout', 'host-gone', 'host-unknown', @@ -66,3 +66,17 @@ class StreamError(Error, StanzaBase): 'unsupported-feature', 'unsupported-stanza-type', 'unsupported-version')) condition_ns = 'urn:ietf:params:xml:ns:xmpp-streams' + + def get_see_other_host(self): + ns = self.condition_ns + return self._get_sub_text('{%s}see-other-host' % ns, '') + + def set_see_other_host(self, value): + del self['condition'] + if value: + ns = self.condition_ns + return self._set_sub_text('{%s}see-other-host' % ns, value) + + def del_see_other_host(self): + self._del_sub('{%s}see-other-host' % self.condition_ns) + -- cgit v1.2.3 From d92aa05b5c18806ab5addc947eeedaaf4d51500e Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 19 Jun 2012 01:29:48 -0700 Subject: PEP8 formatting updates. --- sleekxmpp/stanza/stream_error.py | 1 - 1 file changed, 1 deletion(-) (limited to 'sleekxmpp/stanza/stream_error.py') diff --git a/sleekxmpp/stanza/stream_error.py b/sleekxmpp/stanza/stream_error.py index bf77d932..8c541da4 100644 --- a/sleekxmpp/stanza/stream_error.py +++ b/sleekxmpp/stanza/stream_error.py @@ -79,4 +79,3 @@ class StreamError(Error, StanzaBase): def del_see_other_host(self): self._del_sub('{%s}see-other-host' % self.condition_ns) - -- cgit v1.2.3 From 019a4b20ae5284ec07d4ecc5e5136be5012e88bd Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 19 Jun 2012 16:21:34 -0700 Subject: Fix assigning values to error stanzas. The new data interfaces were deleting the actual error conditions if they were set afterward with falsy data. --- sleekxmpp/stanza/stream_error.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/stanza/stream_error.py') diff --git a/sleekxmpp/stanza/stream_error.py b/sleekxmpp/stanza/stream_error.py index 8c541da4..ed0078c9 100644 --- a/sleekxmpp/stanza/stream_error.py +++ b/sleekxmpp/stanza/stream_error.py @@ -72,10 +72,12 @@ class StreamError(Error, StanzaBase): return self._get_sub_text('{%s}see-other-host' % ns, '') def set_see_other_host(self, value): - del self['condition'] if value: + del self['condition'] ns = self.condition_ns return self._set_sub_text('{%s}see-other-host' % ns, value) + elif self['condition'] == 'see-other-host': + del self['condition'] def del_see_other_host(self): self._del_sub('{%s}see-other-host' % self.condition_ns) -- cgit v1.2.3