aboutsummaryrefslogtreecommitdiffstats
path: root/sleekxmpp/stanza/error.py
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2010-12-31 19:19:25 +0100
committerThibaut Horel <thibaut.horel@gmail.com>2010-12-31 19:19:25 +0100
commitd90aec17e2201f256783a531c548dcc9857c889d (patch)
tree56b6d0580ee1993c73e67c63d4a452a81bbaaf1e /sleekxmpp/stanza/error.py
parentaf76bcdf7a947702eaa19d39f5b9ecfcd7ec6fd2 (diff)
downloadalias-d90aec17e2201f256783a531c548dcc9857c889d.tar.gz
Cleanup of repository. Bases of webclient.
* remove sleekxmpp (install guideline in server/README) * move server code to server directory * webclient directory with basic strophejs example
Diffstat (limited to 'sleekxmpp/stanza/error.py')
-rw-r--r--sleekxmpp/stanza/error.py141
1 files changed, 0 insertions, 141 deletions
diff --git a/sleekxmpp/stanza/error.py b/sleekxmpp/stanza/error.py
deleted file mode 100644
index 09229bc..0000000
--- a/sleekxmpp/stanza/error.py
+++ /dev/null
@@ -1,141 +0,0 @@
-"""
- 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.xmlstream import ElementBase, ET, register_stanza_plugin
-
-
-class Error(ElementBase):
-
- """
- XMPP stanzas of type 'error' should include an <error> 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.
-
- 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.
- </text>
- </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.
- 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 <text> element.
- set_text -- Set the contents of the <text> element.
- del_text -- Remove the <text> element.
- """
-
- namespace = 'jabber:client'
- name = 'error'
- plugin_attrib = 'error'
- interfaces = set(('code', 'condition', 'text', 'type'))
- sub_interfaces = set(('text',))
- conditions = set(('bad-request', 'conflict', 'feature-not-implemented',
- 'forbidden', 'gone', 'internal-server-error',
- 'item-not-found', 'jid-malformed', 'not-acceptable',
- 'not-allowed', 'not-authorized', 'payment-required',
- 'recipient-unavailable', 'redirect',
- 'registration-required', 'remote-server-not-found',
- 'remote-server-timeout', 'resource-constraint',
- 'service-unavailable', 'subscription-required',
- 'undefined-condition', 'unexpected-request'))
- condition_ns = 'urn:ietf:params:xml:ns:xmpp-stanzas'
- types = set(('cancel', 'continue', 'modify', 'auth', 'wait'))
-
- def setup(self, xml=None):
- """
- Populate the stanza object using an optional XML object.
-
- Overrides ElementBase.setup.
-
- Sets a default error type and condition, and changes the
- parent stanza's type to 'error'.
-
- Arguments:
- xml -- Use an existing XML object for the stanza's values.
- """
- # To comply with PEP8, method names now use underscores.
- # Deprecated method names are re-mapped for backwards compatibility.
- self.getCondition = self.get_condition
- self.setCondition = self.set_condition
- self.delCondition = self.del_condition
- self.getText = self.get_text
- self.setText = self.set_text
- self.delText = self.del_text
-
- if ElementBase.setup(self, xml):
- #If we had to generate XML then set default values.
- self['type'] = 'cancel'
- self['condition'] = 'feature-not-implemented'
- if self.parent is not None:
- self.parent()['type'] = 'error'
-
- def get_condition(self):
- """Return the condition element's name."""
- for child in self.xml.getchildren():
- if "{%s}" % self.condition_ns in child.tag:
- return child.tag.split('}', 1)[-1]
- return ''
-
- def set_condition(self, value):
- """
- Set the tag name of the condition element.
-
- Arguments:
- value -- The tag name of the condition element.
- """
- if value in self.conditions:
- del self['condition']
- self.xml.append(ET.Element("{%s}%s" % (self.condition_ns, value)))
- return self
-
- def del_condition(self):
- """Remove the condition element."""
- for child in self.xml.getchildren():
- if "{%s}" % self.condition_ns in child.tag:
- tag = child.tag.split('}', 1)[-1]
- if tag in self.conditions:
- self.xml.remove(child)
- return self
-
- def get_text(self):
- """Retrieve the contents of the <text> element."""
- return self._get_sub_text('{%s}text' % self.condition_ns)
-
- def set_text(self, value):
- """
- Set the contents of the <text> element.
-
- Arguments:
- value -- The new contents for the <text> element.
- """
- self._set_sub_text('{%s}text' % self.condition_ns, text=value)
- return self
-
- def del_text(self):
- """Remove the <text> element."""
- self._del_sub('{%s}text' % self.condition_ns)
- return self