summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/stanza/stream_error.py36
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py3
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py6
3 files changed, 29 insertions, 16 deletions
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 <error> 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:
- <error type="cancel" code="404">
- <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
- <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
- The item was not found.
+ <stream:error>
+ <not-well-formed xmlns="urn:ietf:params:xml:ns:xmpp-streams" />
+ <text xmlns="urn:ietf:params:xml:ns:xmpp-streams">
+ XML was not well-formed.
</text>
- </error>
+ </stream:error>
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'
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index 558ab743..3937a7a9 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -14,6 +14,7 @@ from xml.etree import cElementTree as ET
from sleekxmpp.xmlstream import JID
from sleekxmpp.xmlstream.tostring import tostring
+from sleekxmpp.thirdparty import OrderedDict
log = logging.getLogger(__name__)
@@ -230,7 +231,7 @@ class ElementBase(object):
self.setStanzaValues = self._set_stanza_values
self.xml = xml
- self.plugins = {}
+ self.plugins = OrderedDict()
self.iterables = []
self._index = 0
self.tag = self.tag_name()
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 39b10a2a..1cd23fba 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -802,7 +802,8 @@ class XMLStream(object):
default_ns = self.default_ns
stanza_type = StanzaBase
for stanza_class in self.__root_stanza:
- if xml.tag == "{%s}%s" % (default_ns, stanza_class.name):
+ if xml.tag == "{%s}%s" % (default_ns, stanza_class.name) or \
+ xml.tag == stanza_class.tag_name():
stanza_type = stanza_class
break
stanza = stanza_type(self, xml)
@@ -827,7 +828,8 @@ class XMLStream(object):
# stanza type applies, a generic StanzaBase stanza will be used.
stanza_type = StanzaBase
for stanza_class in self.__root_stanza:
- if xml.tag == "{%s}%s" % (self.default_ns, stanza_class.name):
+ if xml.tag == "{%s}%s" % (self.default_ns, stanza_class.name) or \
+ xml.tag == stanza_class.tag_name():
stanza_type = stanza_class
break
stanza = stanza_type(self, xml)