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

Class DataForm

source code

simplexml.Node --+
                 |
                DataForm

DataForm class. Used for manipulating dataforms in XMPP. Relevant XEPs: 0004, 0068, 0122. Can be used in disco, pub-sub and many other applications.

Instance Methods [hide private]
 
__init__(self, typ=None, data=[], title=None, node=None)
Create new dataform of type 'typ'.
source code
 
getType(self)
Return the type of dataform.
source code
 
setType(self, typ)
Set the type of dataform.
source code
 
getTitle(self)
Return the title of dataform.
source code
 
setTitle(self, text)
Set the title of dataform.
source code
 
getInstructions(self)
Return the instructions of dataform.
source code
 
setInstructions(self, text)
Set the instructions of dataform.
source code
 
addInstructions(self, text)
Add one more instruction to the dataform.
source code
 
getField(self, name)
Return the datafield object with name 'name' (if exists).
source code
 
setField(self, name)
Create if nessessary or get the existing datafield object with name 'name' and return it.
source code
 
asDict(self)
Represent dataform as simple dictionary mapping of datafield names to their values.
source code
 
__getitem__(self, name)
Simple dictionary interface for getting datafields values by their names.
source code
 
__setitem__(self, name, val)
Simple dictionary interface for setting datafields values by their names.
source code

Inherited from simplexml.Node: __delitem__, __getattr__, __str__, addChild, addData, clearData, delAttr, delChild, getAttr, getAttrs, getCDATA, getChildren, getData, getName, getNamespace, getParent, getPayload, getTag, getTagAttr, getTagData, getTags, has_attr, setAttr, setData, setName, setNamespace, setParent, setPayload, setTag, setTagAttr, setTagData

Class Variables [hide private]

Inherited from simplexml.Node: FORCE_NODE_RECREATION

Method Details [hide private]

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

source code 

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: simplexml.Node.__init__

__getitem__(self, name)
(Indexing operator)

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

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

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