Package pyxmpp :: Module objects :: Class StanzaPayloadObject
[hide private]

Class StanzaPayloadObject

source code

object --+
         |
        StanzaPayloadObject
Known Subclasses:

Base class for objects that may be used as XMPP stanza payload and don't keep internal XML representation, only parsed values.

Provides as_xml method. Derived classes must override xml_element_name and xml_element_namespace class attributes and the complete_xml_element method.

Please note that not all classes derived from StanzaPayloadObject should be used directly as stanza payload. Some of them are parts of higher level objects.

Instance Methods [hide private]
libxml2.xmlNode or libxml2.xmlDoc
as_xml(self, parent=None, doc=None)
Get the XML representation of self.
source code
 
complete_xml_element(self, xmlnode, doc)
Complete the XML node with self content.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
: unicode xml_element_name = None
: name for the XML element provided by the class.
: unicode xml_element_namespace = None
: namespace URI for the XML element provided by the class.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

as_xml(self, parent=None, doc=None)

source code 

Get the XML representation of self.

New document will be created if no parent and no doc is given.

Parameters:
  • parent (: libxml2.xmlNode) - : the parent for the XML element.
  • doc (: libxml2.xmlDoc) - : the document where the element should be created. If not given and parent is provided then autodetection is attempted. If that fails, then common_doc is used.
Returns: libxml2.xmlNode or libxml2.xmlDoc
the new XML element or document created.

complete_xml_element(self, xmlnode, doc)

source code 

Complete the XML node with self content.

Should be overriden in classes derived from StanzaPayloadObject.

Parameters:
  • xmlnode (: libxml2.xmlNode) - : XML node with the element being built. It has already right name and namespace, but no attributes or content.
  • doc (: libxml2.xmlDoc) - : document to which the element belongs.