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

Type Item

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

:Ivariables:
    - `fields`: the fields of the item.
:Types:
    - `fields`: `list` of `Field`.

Method Summary
  __init__(self, fields)
Initialize an `Item` object.
  __contains__(self, name)
  __getitem__(self, name_or_index)
  __iter__(self)
  add_field(self, name, values, field_type, label, options, required, desc, value)
Add a field to the item.
  complete_xml_element(self, xmlnode, doc)
Complete the XML node with `self` content.
  _new_from_xml(cls, xmlnode)
Create a new `Item` object from an XML element. (Class method)
    Inherited from StanzaPayloadObject
  as_xml(self, parent, doc)
Get the XML representation of `self`.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
str xml_element_name = 'item'
str xml_element_namespace = 'jabber:x:data'

Instance Method Details

__init__(self, fields=None)
(Constructor)

Initialize an `Item` object.

:Parameters:
    - `fields`: item fields.
:Types:
    - `fields`: `list` of `Field`.
Overrides:
__builtin__.object.__init__

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.

:Parameters:
    - `name`: field name.
    - `values`: raw field values. Not to be used together with `value`.
    - `field_type`: field type.
    - `label`: field label.
    - `options`: optional values for the field.
    - `required`: `True` if the field is required.
    - `desc`: natural-language description of the field.
    - `value`: field value or values in a field_type-specific type. May be used only
      if `values` parameter is not provided.
:Types:
    - `name`: `unicode`
    - `values`: `list` of `unicode`
    - `field_type`: `str`
    - `label`: `unicode`
    - `options`: `list` of `Option`
    - `required`: `bool`
    - `desc`: `unicode`
    - `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.

:return: the field added.
:returntype: `Field`

complete_xml_element(self, xmlnode, doc)

Complete the XML node with `self` content.

:Parameters:
    - `xmlnode`: XML node with the element being built. It has already
      right name and namespace, but no attributes or content.
    - `doc`: document to which the element belongs.
:Types:
    - `xmlnode`: `libxml2.xmlNode`
    - `doc`: `libxml2.xmlDoc`
Overrides:
pyxmpp.objects.StanzaPayloadObject.complete_xml_element

Class Method Details

_new_from_xml(cls, xmlnode)

Create a new `Item` object from an XML element.

:Parameters:
    - `xmlnode`: the XML element.
:Types:
    - `xmlnode`: `libxml2.xmlNode`

:return: the object created.
:returntype: `Item`

Class Variable Details

xml_element_name

Type:
str
Value:
'item'                                                                 

xml_element_namespace

Type:
str
Value:
'jabber:x:data'                                                        

Generated by Epydoc 2.1 on Wed May 31 22:36:59 2006 http://epydoc.sf.net