pyxmpp.jabber.dataforms.Item

Package pyxmpp :: Package jabber :: Module dataforms :: Class Item |
[hide private]

# Class Item

source code

                     object --+
                              |
    objects.StanzaPayloadObject --+
                                  |
                                 Item

An item of multi-item form data (e.g. a search result).

Additionally to the direct access to the contained fields via the fields attribute, Item object provides an iterator and mapping interface for field access. E.g.:

    for field in item:
        ...

or:

    field = item['field_name']

or:

    if 'field_name' in item:
        ...

Instance Methods | [hide private]
__init__(self, fields=None) Initialize an Item object. | source code
__getitem__(self, name_or_index) | source code
__contains__(self, name) | source code
__iter__(self) | source code
Field |
add_field(self, name=None, values=None, field_type=None, label=None, options=None, required=False, desc=None, value=None) Add a field to the item. | source code
complete_xml_element(self, xmlnode, doc) Complete the XML node with `self` content. | source code
Inherited from `objects.StanzaPayloadObject`: `as_xml` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Methods | [hide private]
Item |
_new_from_xml(cls, xmlnode) Create a new Item object from an XML element. | source code

Class Variables | [hide private]
`unicode` | xml_element_name = ``'``item``'`` name for the XML element provided by the class.
`unicode` | xml_element_namespace = ``'``jabber:x:data``'`` namespace URI for the XML element provided by the class.

Instance Variables | [hide private]
`list` of Field. | fields the fields of the item.

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

Method Details | [hide private]

### __init__(self, fields=None) (Constructor) | source code
Initialize an Item object. Parameters: `fields` (`list` of Field.) - item fields. Overrides: object.__init__

### add_field(self, name=None, values=None, field_type=None, label=None, options=None, required=False, desc=None, value=None) | source code
Add a field to the item. Parameters: `name` (`unicode`) - field name. `values` (`list` of `unicode`) - raw field values. Not to be used together with `value`. `field_type` (`str`) - field type. `label` (`unicode`) - field label. `options` (`list` of Option) - optional values for the field. `required` (`bool`) - `True` if the field is required. `desc` (`unicode`) - natural-language description of the field. `value` (`bool` for "boolean" field, JID for "jid-single", `list` of JID for "jid-multi", `list` of `unicode` for "list-multi" and "text-multi" and `unicode` for other field types.) - field value or values in a field_type-specific type. May be used only if `values` parameter is not provided. Returns: Field the field added.

### complete_xml_element(self, xmlnode, doc) | source code
Complete the XML node with `self` content. 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. Overrides: objects.StanzaPayloadObject.complete_xml_element

### _new_from_xml(cls, xmlnode) Class Method | source code
Create a new Item object from an XML element. Parameters: `xmlnode` (`libxml2.xmlNode`) - the XML element. Returns: Item the object created.