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

Class ErrorNode

Known Subclasses:
StanzaErrorNode, StreamErrorNode

Base class for both XMPP stream and stanza errors
Method Summary
  __init__(self, xmlnode_or_cond, ns, copy, parent)
Initialize an ErrorNode object.
  __del__(self)
libxml2.xmlNode add_custom_condition(self, ns, cond, content)
Add custom condition element to the error.
  downgrade(self)
Downgrade an XMPP error element to the legacy format.
  free(self)
Free the associated XML node.
  free_borrowed(self)
Free the associated "borrowed" XML node.
libxml2.xmlNode get_condition(self, ns)
Get the condition element of the error.
unicode get_text(self)
Get the description text from the error element.
bool is_legacy(self)
Check if the error node is a legacy error element.
str serialize(self)
Serialize the element node.
  upgrade(self)
Upgrade a legacy error element to the XMPP compliant one.
  xpath_eval(self, expr, namespaces)
Evaluate XPath expression on the error element.

Method Details

__init__(self, xmlnode_or_cond, ns=None, copy=True, parent=None)
(Constructor)

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

add_custom_condition(self, ns, cond, content=None)

Add custom condition element to the error.
Parameters:
ns - namespace URI.
           (type=unicode)
cond - condition name.
           (type=unicode)
content - content of the element.
           (type=unicode)
Returns:
the new condition element.
           (type=libxml2.xmlNode)

downgrade(self)

Downgrade an XMPP error element to the legacy format.

Add a numeric code attribute according to the condition name.

free(self)

Free the associated XML node.

free_borrowed(self)

Free the associated "borrowed" XML node.

get_condition(self, ns=None)

Get the condition element of the error.
Parameters:
ns - namespace URI of the condition element if it is not the XMPP namespace of the error element.
           (type=unicode)
Returns:
the condition element or None.
           (type=libxml2.xmlNode)

get_text(self)

Get the description text from the error element.
Returns:
the text provided with the error or None.
           (type=unicode)

is_legacy(self)

Check if the error node is a legacy error element.
Returns:
True if it is a legacy error.
           (type=bool)

serialize(self)

Serialize the element node.
Returns:
serialized element in UTF-8 encoding.
           (type=str)

upgrade(self)

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.

xpath_eval(self, expr, namespaces=None)

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 - the XPath expression.
           (type=unicode)
namespaces - prefix to namespace mapping.
           (type=dict)
Returns:
the result of the expression evaluation.