From 2004ddd678fae9af590db2065478d2592bc2530b Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sun, 16 Jan 2011 13:22:52 -0500 Subject: Add StreamError stanza and a stream_error event. Note that the stream may automatically attempt to reconnect when a stream error is received. --- sleekxmpp/stanza/stream_error.py | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 sleekxmpp/stanza/stream_error.py (limited to 'sleekxmpp/stanza/stream_error.py') diff --git a/sleekxmpp/stanza/stream_error.py b/sleekxmpp/stanza/stream_error.py new file mode 100644 index 00000000..dd0c119d --- /dev/null +++ b/sleekxmpp/stanza/stream_error.py @@ -0,0 +1,59 @@ +""" + SleekXMPP: The Sleek XMPP Library + Copyright (C) 2010 Nathanael C. Fritz + This file is part of SleekXMPP. + + See the file LICENSE for copying permission. +""" + +from sleekxmpp.stanza.error import Error +from sleekxmpp.xmlstream import ElementBase, ET, register_stanza_plugin + + +class StreamError(Error): + + """ + XMPP stanzas of type 'error' should include an stanza that + describes the nature of the error and how it should be handled. + + Use the 'XEP-0086: Error Condition Mappings' plugin to include error + codes used in older XMPP versions. + + The stream:error stanza is used to provide more information for + error that occur with the underlying XML stream itself, and not + a particular stanza. + + Note: The StreamError stanza is the same as the normal Error stanza, + but with a different namespace. + + Example error stanza: + + + + The item was not found. + + + + Stanza Interface: + code -- The error code used in older XMPP versions. + condition -- The name of the condition element. + text -- Human readable description of the error. + type -- Error type indicating how the error should be handled. + + Attributes: + conditions -- The set of allowable error condition elements. + condition_ns -- The namespace for the condition element. + types -- A set of values indicating how the error + should be treated. + + Methods: + setup -- Overrides ElementBase.setup. + get_condition -- Retrieve the name of the condition element. + set_condition -- Add a condition element. + del_condition -- Remove the condition element. + get_text -- Retrieve the contents of the element. + set_text -- Set the contents of the element. + del_text -- Remove the element. + """ + + namespace = 'http://etherx.jabber.org/streams' -- cgit v1.2.3 From 40642b2cd1460678a6cdaa5bf64b93248a11b523 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 27 Jan 2011 16:02:57 -0500 Subject: Make StreamError work properly. Now uses the correct namespaces and condition names. --- sleekxmpp/stanza/stream_error.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'sleekxmpp/stanza/stream_error.py') diff --git a/sleekxmpp/stanza/stream_error.py b/sleekxmpp/stanza/stream_error.py index dd0c119d..cf59a7fa 100644 --- a/sleekxmpp/stanza/stream_error.py +++ b/sleekxmpp/stanza/stream_error.py @@ -7,10 +7,11 @@ """ from sleekxmpp.stanza.error import Error -from sleekxmpp.xmlstream import ElementBase, ET, register_stanza_plugin +from sleekxmpp.xmlstream import StanzaBase, ElementBase, ET +from sleekxmpp.xmlstream import register_stanza_plugin -class StreamError(Error): +class StreamError(Error, StanzaBase): """ XMPP stanzas of type 'error' should include an stanza that @@ -23,28 +24,25 @@ class StreamError(Error): error that occur with the underlying XML stream itself, and not a particular stanza. - Note: The StreamError stanza is the same as the normal Error stanza, - but with a different namespace. + Note: The StreamError stanza is mostly the same as the normal + Error stanza, but with different namespaces and + condition names. Example error stanza: - - - - The item was not found. + + + + XML was not well-formed. - + Stanza Interface: - code -- The error code used in older XMPP versions. condition -- The name of the condition element. text -- Human readable description of the error. - type -- Error type indicating how the error should be handled. Attributes: conditions -- The set of allowable error condition elements. condition_ns -- The namespace for the condition element. - types -- A set of values indicating how the error - should be treated. Methods: setup -- Overrides ElementBase.setup. @@ -57,3 +55,15 @@ class StreamError(Error): """ namespace = 'http://etherx.jabber.org/streams' + interfaces = set(('condition', 'text')) + conditions = set(( + 'bad-format', 'bad-namespace-prefix', 'conflict', + 'connection-timeout', 'host-gone', 'host-unknown', + 'improper-addressing', 'internal-server-error', 'invalid-from', + 'invalid-namespace', 'invalid-xml', 'not-authorized', + 'not-well-formed', 'policy-violation', 'remote-connection-failed', + 'reset', 'resource-constraint', 'restricted-xml', 'see-other-host', + 'system-shutdown', 'undefined-condition', 'unsupported-encoding', + 'unsupported-feature', 'unsupported-stanza-type', + 'unsupported-version')) + condition_ns = 'urn:ietf:params:xml:ns:xmpp-streams' -- cgit v1.2.3