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)
  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.
  get_condition(self, ns)
Get the condition element of the error.
  get_text(self)
Get the description text from the error element.
  is_legacy(self)
Check if the error node is a legacy error element.
  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.
  __from_xml(self, xmlnode, ns, copy, parent)
Initialize an ErrorNode object from an XML node.

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.
    - `ns`: XML namespace URI of the error condition element (to be
      used when the provided node has no namespace).
    - `copy`: When `True` then the XML node will be copied,
      otherwise it is only borrowed.
    - `parent`: Parent node for the XML node to be copied or created.
:Types:
    - `xmlnode_or_cond`: `libxml2.xmlNode` or `unicode`
    - `ns`: `unicode`
    - `copy`: `bool`
    - `parent`: `libxml2.xmlNode`

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

Add custom condition element to the error.

:Parameters:
    - `ns`: namespace URI.
    - `cond`: condition name.
    - `content`: content of the element.

:Types:
    - `ns`: `unicode`
    - `cond`: `unicode`
    - `content`: `unicode`

:return: the new condition element.
:returntype: `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.
:Types:
    - `ns`: `unicode`

:return: the condition element or `None`.
:returntype: `libxml2.xmlNode`

get_text(self)

Get the description text from the error element.

:return: the text provided with the error or `None`.
:returntype: `unicode`

is_legacy(self)

Check if the error node is a legacy error element.

:return: `True` if it is a legacy error.
:returntype: `bool`

serialize(self)

Serialize the element node.

:return: serialized element in UTF-8 encoding.
:returntype: `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.
    - `namespaces`: prefix to namespace mapping.
:Types:
    - `expr`: `unicode`
    - `namespaces`: `dict`

:return: the result of the expression evaluation.

__from_xml(self, xmlnode, ns, copy, parent)

Initialize an ErrorNode object from an XML node.

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

Generated by Epydoc 2.1 on Wed May 31 22:36:59 2006 http://epydoc.sf.net