Package xmpp :: Module protocol :: Class DataForm
[show private | hide private]
[frames | no frames]

Class DataForm

Node --+
       |
      DataForm


DataForm class. Used for manipulating dataforms in XMPP. Relevant JEPs: 0004, 0068, 0122. Can be used in disco, pub-sub and many other applications.
Method Summary
  __init__(self, typ, data, title, node)
Create new dataform of type 'typ'.
  __getitem__(self, name)
Simple dictionary interface for getting datafields values by their names.
  __setitem__(self, name, val)
Simple dictionary interface for setting datafields values by their names.
  addInstructions(self, text)
Add one more instruction to the dataform.
  asDict(self)
Represent dataform as simple dictionary mapping of datafield names to their values.
  getField(self, name)
Return the datafield object with name 'name' (if exists).
  getInstructions(self)
Return the instructions of dataform.
  getTitle(self)
Return the title of dataform.
  getType(self)
Return the type of dataform.
  setField(self, name)
Create if nessessary or get the existing datafield object with name 'name' and return it.
  setInstructions(self, text)
Set the instructions of dataform.
  setTitle(self, text)
Set the title of dataform.
  setType(self, typ)
Set the type of dataform.
    Inherited from Node
  __delitem__(self, item)
Deletes node's attribute "item".
  __getattr__(self, attr)
Reduce memory usage caused by T/NT classes - use memory only when needed.
  __str__(self, fancy)
Method used to dump node into textual representation.
  addChild(self, name, attrs, payload, namespace, node)
If "node" argument is provided, adds it as child node.
  addData(self, data)
Adds some CDATA to node.
  clearData(self)
Removes all CDATA from the node.
  delAttr(self, key)
Deletes an attribute "key"
  delChild(self, node, attrs)
Deletes the "node" from the node's childs list, if "node" is an instance.
  getAttr(self, key)
Returns value of specified attribute.
  getAttrs(self)
Returns all node's attributes as dictionary.
  getCDATA(self)
Serialise node, dropping all tags and leaving CDATA intact.
  getChildren(self)
Returns all node's child nodes as list.
  getData(self)
Returns all node CDATA as string (concatenated).
  getName(self)
Returns the name of node
  getNamespace(self)
Returns the namespace of node
  getParent(self)
Returns the parent of node (if present).
  getPayload(self)
Return the payload of node i.e.
  getTag(self, name, attrs, namespace)
Filters all child nodes using specified arguments as filter.
  getTagAttr(self, tag, attr)
Returns attribute value of the child with specified name (or None if no such attribute).
  getTagData(self, tag)
Returns cocatenated CDATA of the child with specified name.
  getTags(self, name, attrs, namespace, one)
Filters all child nodes using specified arguments as filter.
  has_attr(self, key)
Checks if node have attribute "key".
  setAttr(self, key, val)
Sets attribute "key" with the value "val".
  setData(self, data)
Sets node's CDATA to provided string.
  setName(self, val)
Changes the node name.
  setNamespace(self, namespace)
Changes the node namespace.
  setParent(self, node)
Sets node's parent to "node".
  setPayload(self, payload, add)
Sets node payload according to the list specified.
  setTag(self, name, attrs, namespace)
Same as getTag but if the node with specified namespace/attributes not found, creates such node and returns it.
  setTagAttr(self, tag, attr, val)
Creates new node (if not already present) with name "tag" and sets it's attribute "attr" to value "val".
  setTagData(self, tag, val, attrs)
Creates new node (if not already present) with name "tag" and (optionally) attributes "attrs" and sets it's CDATA to string "val".

Class Variable Summary
    Inherited from Node
int FORCE_NODE_RECREATION = 0                                                                     

Method Details

__init__(self, typ=None, data=[], title=None, node=None)
(Constructor)

Create new dataform of type 'typ'. 'data' is the list of DataField instances that this dataform contains, 'title' - the title string. You can specify the 'node' argument as the other node to be used as base for constructing this dataform.

title and instructions is optional and SHOULD NOT contain newlines. Several instructions MAY be present. 'typ' can be one of ('form' | 'submit' | 'cancel' | 'result' ) 'typ' of reply iq can be ( 'result' | 'set' | 'set' | 'result' ) respectively. 'cancel' form can not contain any fields. All other forms contains AT LEAST one field. 'title' MAY be included in forms of type "form" and "result"
Overrides:
xmpp.simplexml.Node.__init__

__getitem__(self, name)
(Indexing operator)

Simple dictionary interface for getting datafields values by their names.
Overrides:
xmpp.simplexml.Node.__getitem__

__setitem__(self, name, val)
(Index assignment operator)

Simple dictionary interface for setting datafields values by their names.
Overrides:
xmpp.simplexml.Node.__setitem__

addInstructions(self, text)

Add one more instruction to the dataform.

asDict(self)

Represent dataform as simple dictionary mapping of datafield names to their values.

getField(self, name)

Return the datafield object with name 'name' (if exists).

getInstructions(self)

Return the instructions of dataform.

getTitle(self)

Return the title of dataform.

getType(self)

Return the type of dataform.

setField(self, name)

Create if nessessary or get the existing datafield object with name 'name' and return it.

setInstructions(self, text)

Set the instructions of dataform.

setTitle(self, text)

Set the title of dataform.

setType(self, typ)

Set the type of dataform.

Generated by Epydoc 2.1 on Thu Oct 5 23:57:44 2006 http://epydoc.sf.net