pyxmpp.stanza.Stanza

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

# Class Stanza

source code

Known Subclasses:
  - presence.Presence
  - , iq.Iq
  - , message.Message

Base class for all XMPP stanzas.

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

Class Variables | [hide private]
| stanza_type = ``'``Unknown``'``

Instance Variables | [hide private]
pyxmpp.error.StanzaErrorNode | _error pyxmpp.error.StanzaErrorNode describing the error associated with the stanza of type "error".
| stream stream on which the stanza was received or `None`.
`libxml2.xmlNode` | xmlnode stanza XML node.

Method Details | [hide private]

### __init__(self, name_or_xmlnode, from_jid=None, to_jid=None, stanza_type=None, stanza_id=None, error=None, error_cond=None, stream=None) (Constructor) | source code
Initialize a Stanza object. Parameters: `name_or_xmlnode` (`unicode` or `libxml2.xmlNode` or Stanza) - 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. `from_jid` (JID) - sender JID. `to_jid` (JID) - recipient JID. `stanza_type` (`unicode`) - staza type: one of: "get", "set", "result" or "error". `stanza_id` (`unicode`) - stanza id -- value of stanza's "id" attribute. If not given, then unique for the session value is generated. `error` (pyxmpp.error.StanzaErrorNode) - error object. Ignored if stanza_type is not "error". `error_cond` (`unicode`) - error condition name. Ignored if stanza_type is not "error" or error is not None.

### add_content(self, content) | source code
Add an XML node to the stanza's payload. Parameters: `content` - XML node to be added to the payload. Types: `content`: `libxml2.xmlNode`, UTF-8 `str` or unicode, or an object with "as_xml()" method.

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

### get_error(self) | source code
Get stanza error information. Returns: pyxmpp.error.StanzaErrorNode object describing the error.

### get_from(self) | source code
Get "from" attribute of the stanza. Returns: JID value of the "from" attribute (sender JID) or None.

### get_from_jid(self) | source code
Get "from" attribute of the stanza. Returns: JID value of the "from" attribute (sender JID) or None.

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

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

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

### get_to(self) | source code
Get "to" attribute of the stanza. Returns: JID value of the "to" attribute (recipient JID) or None.

### get_to_jid(self) | source code
Get "to" attribute of the stanza. Returns: JID value of the "to" attribute (recipient JID) or None.

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

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

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

### set_from(self, from_jid) | source code
Set "from" attribute of the stanza. Parameters: `from_jid` (JID) - new value of the "from" attribute (sender JID).

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

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

### set_to(self, to_jid) | source code
Set "to" attribute of the stanza. Parameters: `to_jid` (JID) - new value of the "to" attribute (recipient JID).

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

### xpath_eval(self, expr, namespaces=None) | source code
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` (`unicode`) - XPath expression. `namespaces` (`dict` or other mapping) - mapping from namespace prefixes to URIs.

Instance Variable Details | [hide private]

### stream stream on which the stanza was received or `None`. May be used to send replies or get some session-related parameters.