nbxmpp.protocol.DataForm

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

# Class DataForm

source code

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'. '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 | 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`: `__contains__`, `__delitem__`, `__getattr__`, `__str__`, `addChild`, `addData`, `clearData`, `delAttr`, `delChild`, `getAttr`, `getAttrs`, `getChildren`, `getData`, `getName`, `getNamespace`, `getParent`, `getPayload`, `getTag`, `getTagAttr`, `getTagData`, `getTags`, `has_attr`, `iterTags`, `lookup_nsp`, `setAttr`, `setData`, `setName`, `setNamespace`, `setParent`, `setPayload`, `setTag`, `setTagAttr`, `setTagData` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Class Variables | [hide private]
Inherited from `simplexml.Node`: `FORCE_NODE_RECREATION`

Properties | [hide private]
Inherited from `object`: `__class__`

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: object.__init__

### getType(self) | source code
Return the type of dataform

### setType(self, typ) | source code
Set the type of dataform

### getTitle(self) | source code
Return the title of dataform

### setTitle(self, text) | source code
Set the title of dataform

### getInstructions(self) | source code
Return the instructions of dataform

### setInstructions(self, text) | source code
Set the instructions of dataform

### addInstructions(self, text) | source code
Add one more instruction to the dataform

### getField(self, name) | source code
Return the datafield object with name 'name' (if exists)

### setField(self, name) | source code
Create if nessessary or get the existing datafield object with name 'name' and return it

### asDict(self) | source code
Represent dataform as simple dictionary mapping of datafield names to their values

### __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__