pyxmpp.stanza.Stanza

Package pyxmpp :: Module stanza :: Class Stanza |
[show private | hide private]
[frames | no frames]

## Class Stanza

Known Subclasses:
  `Iq`, `Message`, `Presence`

Base class for all XMPP stanzas.

Method Summary
| ``__init__`(self, name_or_xmlnode, from_jid, to_jid, stanza_type, stanza_id, error, error_cond)` Initialize a Stanza object.
| `__del__(self)`
| `__eq__(self, other)`
| `__ne__(self, other)`
| ``add_content`(self, content)` Add an XML node to the stanza's payload.
| ``add_new_content`(self, ns_uri, name)` Add a new XML element to the stanza payload.
`Stanza` | ``copy`(self)` Create a deep copy of the stanza.
| ``free`(self)` Free the node associated with this `Stanza` object.
`pyxmpp.error.StanzaErrorNode` | ``get_error`(self)` Get stanza error information.
`unicode` | ``get_from`(self)` Get "from" attribute of the stanza.
`unicode` | ``get_from_jid`(self)` Get "from" attribute of the stanza.
`unicode` | ``get_id`(self)` Get "id" attribute of the stanza.
`libxml2.xmlNode` | ``get_node`(self)` Return the XML node wrapped into `self`.
`unicode` | ``get_stanza_id`(self)` Get "id" attribute of the stanza.
`unicode` | ``get_stanza_type`(self)` Get "type" attribute of the stanza.
`unicode` | ``get_to`(self)` Get "to" attribute of the stanza.
`unicode` | ``get_to_jid`(self)` Get "to" attribute of the stanza.
`unicode` | ``get_type`(self)` Get "type" attribute of the stanza.
`str` | ``serialize`(self)` Serialize the stanza into an UTF-8 encoded XML string.
| ``set_content`(self, content)` Set stanza content to an XML node.
| ``set_from`(self, from_jid)` Set "from" attribute of the stanza.
| ``set_id`(self, stanza_id)` Set "id" attribute of the stanza.
| ``set_new_content`(self, ns_uri, name)` Set stanza payload to a new XML element.
| ``set_to`(self, to_jid)` Set "to" attribute of the stanza.
| ``set_type`(self, stanza_type)` Set "type" attribute of the stanza.
| ``xpath_eval`(self, expr, namespaces)` Evaluate an XPath expression on the stanza XML node.

Instance Variable Summary
`libxml2.xmlNode` | `xmlnode`: stanza XML node.
`pyxmpp.error.StanzaErrorNode` | `_error`: `pyxmpp.error.StanzaErrorNode` describing the error associated with the stanza of type "error".

Class Variable Summary
`str` | `stanza_type` = `'Unknown'`

Method Details

### __init__(self, name_or_xmlnode, from_jid=None, to_jid=None, stanza_type=None, stanza_id=None, error=None, error_cond=None) (Constructor) Initialize a Stanza object. Parameters: `name_or_xmlnode` - XML node to be wrapped into the Stanza object or other Presence object to be copied. If not given then new presence stanza is created using following parameters. (type=`unicode` or `libxml2.xmlNode` or `Stanza`) `from_jid` - sender JID. (type=`JID`) `to_jid` - recipient JID. (type=`JID`) `stanza_type` - staza type: one of: "get", "set", "result" or "error". (type=`unicode`) `stanza_id` - stanza id -- value of stanza's "id" attribute. If not given, then unique for the session value is generated. (type=`unicode`) `error` - error object. Ignored if `stanza_type` is not "error". (type=`pyxmpp.error.StanzaErrorNode`) `error_cond` - error condition name. Ignored if `stanza_type` is not "error" or `error` is not None. (type=`unicode`)

### add_content(self, content) Add an XML node to the stanza's payload. Parameters: `content` - XML node to be added to the payload. (type=`libxml2.xmlNode` or UTF-8 `str`)

### add_new_content(self, ns_uri, name) Add a new XML element to the stanza payload. Parameters: `ns_uri` - XML namespace URI of the element. (type=`str`) `name` - element name. (type=`str` or `unicode`)

### copy(self) Create a deep copy of the stanza. Returns: `Stanza`

### free(self) Free the node associated with this `Stanza` object.

### get_error(self) Get stanza error information. Returns: object describing the error. (type=`pyxmpp.error.StanzaErrorNode`)

### get_from(self) Get "from" attribute of the stanza. Returns: value of the "from" attribute (sender JID) or None. (type=`unicode`)

### get_from_jid(self) Get "from" attribute of the stanza. Returns: value of the "from" attribute (sender JID) or None. (type=`unicode`)

### get_id(self) Get "id" attribute of the stanza. Returns: value of the "id" attribute (stanza identifier) or None. (type=`unicode`)

### get_node(self) Return the XML node wrapped into `self`. Returns: `libxml2.xmlNode`

### get_stanza_id(self) Get "id" attribute of the stanza. Returns: value of the "id" attribute (stanza identifier) or None. (type=`unicode`)

### get_stanza_type(self) Get "type" attribute of the stanza. Returns: value of the "type" attribute (stanza type) or None. (type=`unicode`)

### get_to(self) Get "to" attribute of the stanza. Returns: value of the "to" attribute (recipient JID) or None. (type=`unicode`)

### get_to_jid(self) Get "to" attribute of the stanza. Returns: value of the "to" attribute (recipient JID) or None. (type=`unicode`)

### get_type(self) Get "type" attribute of the stanza. Returns: value of the "type" attribute (stanza type) or None. (type=`unicode`)

### serialize(self) Serialize the stanza into an UTF-8 encoded XML string. Returns: serialized stanza. (type=`str`)

### set_content(self, content) Set stanza content to an XML node. Parameters: `content` - XML node to be included in the stanza. (type=`libxml2.xmlNode` or UTF-8 `str`)

### set_from(self, from_jid) Set "from" attribute of the stanza. Parameters: `from_jid` - new value of the "from" attribute (sender JID). (type=`unicode`)

### set_id(self, stanza_id) Set "id" attribute of the stanza. Parameters: `stanza_id` - new value of the "id" attribute (stanza identifier). (type=`unicode`)

### set_new_content(self, ns_uri, name) Set stanza payload to a new XML element. Parameters: `ns_uri` - XML namespace URI of the element. (type=`str`) `name` - element name. (type=`str` or `unicode`)

### set_to(self, to_jid) Set "to" attribute of the stanza. Parameters: `to_jid` - new value of the "to" attribute (recipient JID). (type=`unicode`)

### set_type(self, stanza_type) Set "type" attribute of the stanza. Parameters: `stanza_type` - new value of the "type" attribute (stanza type). (type=`unicode`)

### xpath_eval(self, expr, namespaces=None) Evaluate an XPath expression on the stanza XML node. 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` - XPath expression. (type=`unicode`) `namespaces` - mapping from namespace prefixes to URIs. (type=`dict` or other mapping)

Instance Variable Details

### xmlnode stanza XML node. Type: `libxml2.xmlNode`

### _error `pyxmpp.error.StanzaErrorNode` describing the error associated with the stanza of type "error". Type: `pyxmpp.error.StanzaErrorNode`

Class Variable Details

    ### stanza_type Type: `str` Value:
        'Unknown'