pyxmpp.error.ErrorNode

Package pyxmpp :: Module error :: Class ErrorNode |
[hide private]

# Class ErrorNode

source code

Known Subclasses:
  - StanzaErrorNode
  - , StreamErrorNode

Base class for both XMPP stream and stanza errors

Instance Methods | [hide private]
__init__(self, xmlnode_or_cond, ns=None, copy=True, parent=None) Initialize an ErrorNode object. | source code
__from_xml(self, xmlnode, ns, copy, parent) Initialize an ErrorNode object from an XML node. | source code
__del__(self) | source code
free(self) Free the associated XML node. | source code
free_borrowed(self) Free the associated "borrowed" XML node. | source code
`bool` |
is_legacy(self) Check if the error node is a legacy error element. | source code
xpath_eval(self, expr, namespaces=None) Evaluate XPath expression on the error element. | source code
`libxml2.xmlNode` |
get_condition(self, ns=None) Get the condition element of the error. | source code
`unicode` |
get_text(self) Get the description text from the error element. | source code
`libxml2.xmlNode` |
add_custom_condition(self, ns, cond, content=None) Add custom condition element to the error. | source code
upgrade(self) Upgrade a legacy error element to the XMPP compliant one. | source code
downgrade(self) Downgrade an XMPP error element to the legacy format. | source code
`str` |
serialize(self) Serialize the element node. | source code

Method Details | [hide private]

### __init__(self, xmlnode_or_cond, ns=None, copy=True, parent=None) (Constructor) | source code
Initialize an ErrorNode object. Parameters: `xmlnode_or_cond` (`libxml2.xmlNode` or `unicode`) - XML node to be wrapped into this object or error condition name. `ns` (`unicode`) - XML namespace URI of the error condition element (to be used when the provided node has no namespace). `copy` (`bool`) - When `True` then the XML node will be copied, otherwise it is only borrowed. `parent` (`libxml2.xmlNode`) - Parent node for the XML node to be copied or created.

### __from_xml(self, xmlnode, ns, copy, parent) | source code
Initialize an ErrorNode object from an XML node. Parameters: `xmlnode` (`libxml2.xmlNode`) - XML node to be wrapped into this object. `ns` (`unicode`) - XML namespace URI of the error condition element (to be used when the provided node has no namespace). `copy` (`bool`) - When `True` then the XML node will be copied, otherwise it is only borrowed. `parent` (`libxml2.xmlNode`) - Parent node for the XML node to be copied or created.

### is_legacy(self) | source code
Check if the error node is a legacy error element. Returns: `bool` `True` if it is a legacy error.

### xpath_eval(self, expr, namespaces=None) | source code
Evaluate XPath expression on the error element. The expression will be evaluated in context where the common namespace (the one used for stanza elements, mapped to 'jabber:client', 'jabber:server', etc.) is bound to prefix "ns" and other namespaces are bound accordingly to the `namespaces` list. Parameters: `expr` (`unicode`) - the XPath expression. `namespaces` (`dict`) - prefix to namespace mapping. Returns: the result of the expression evaluation.

### get_condition(self, ns=None) | source code
Get the condition element of the error. Parameters: `ns` (`unicode`) - namespace URI of the condition element if it is not the XMPP namespace of the error element. Returns: `libxml2.xmlNode` the condition element or `None`.

### get_text(self) | source code
Get the description text from the error element. Returns: `unicode` the text provided with the error or `None`.

### add_custom_condition(self, ns, cond, content=None) | source code
Add custom condition element to the error. Parameters: `ns` (`unicode`) - namespace URI. `cond` (`unicode`) - condition name. `content` (`unicode`) - content of the element. Returns: `libxml2.xmlNode` the new condition element.

### upgrade(self) | source code
Upgrade a legacy error element to the XMPP compliant one. Use the error code provided to select the condition and the <error/> CDATA for the error text.

### downgrade(self) | source code
Downgrade an XMPP error element to the legacy format. Add a numeric code attribute according to the condition name.

### serialize(self) | source code
Serialize the element node. Returns: `str` serialized element in UTF-8 encoding.