XEP-0004: Data Forms¶
Stanza elements¶
- class slixmpp.plugins.xep_0004.stanza.field.FieldOption(xml=None, parent=None)[source]¶
- interfaces: ClassVar[Set[str]] = {'label', 'value'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attribvalue of any registered stanza plugins.
- iterables: List[ElementBase]¶
A list of child stanzas whose class is included in
plugin_iterables.
- loaded_plugins: Set[str]¶
- name: ClassVar[str] = 'option'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'jabber:x:data'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- parent: Optional[ReferenceType[ElementBase]]¶
A
weakref.weakrefto the parent stanza, if there is one. If not, thenparentisNone.
- plugin_attrib: ClassVar[str] = 'option'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- plugin_multi_attrib: ClassVar[str] = 'options'¶
For
ElementBasesubclasses that are intended to be an iterable group of items, theplugin_multi_attribvalue defines an interface for the parent stanza which returns the entire group of matching substanzas. So the following are equivalent:# Given stanza class Foo, with plugin_multi_attrib = 'foos' parent['foos'] filter(isinstance(item, Foo), parent['substanzas'])
- plugins: Dict[Tuple[str, Optional[str]], ElementBase]¶
An ordered dictionary of plugin stanzas, mapped by their
plugin_attribvalue.
- sub_interfaces: ClassVar[Set[str]] = {'value'}¶
A subset of
interfaceswhich maps interfaces to direct subelements of the underlying XML object. Using this set, the text of these subelements may be set, retrieved, or removed without needing to define custom methods.
- tag: str¶
The name of the tag for the stanza’s root element. It is the same as calling
tag_name()and is formatted as'{namespace}elementname'.
- xml: ET.Element¶
The underlying XML object for the stanza. It is a standard
xml.etree.ElementTreeobject.
- class slixmpp.plugins.xep_0004.stanza.field.FormField(xml=None, parent=None)[source]¶
- addOption(label='', value='')¶
- delOptions()¶
- delRequired()¶
- delValue()¶
- field_types = {'boolean', 'fixed', 'hidden', 'jid-multi', 'jid-single', 'list-multi', 'list-single', 'text-multi', 'text-private', 'text-single'}¶
- getAnswer()¶
- getOptions()¶
- getRequired()¶
- getValue(convert=True)¶
- interfaces: ClassVar[Set[str]] = {'answer', 'desc', 'label', 'required', 'type', 'value', 'var'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attribvalue of any registered stanza plugins.
- iterables: List[ElementBase]¶
A list of child stanzas whose class is included in
plugin_iterables.
- loaded_plugins: Set[str]¶
- multi_line_types = {'hidden', 'text-multi'}¶
- multi_value_types = {'hidden', 'jid-multi', 'list-multi', 'text-multi'}¶
- name: ClassVar[str] = 'field'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'jabber:x:data'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- option_types = {'list-multi', 'list-single'}¶
- parent: Optional[ReferenceType[ElementBase]]¶
A
weakref.weakrefto the parent stanza, if there is one. If not, thenparentisNone.
- plugin_attrib: ClassVar[str] = 'field'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- plugin_attrib_map: ClassVar[Dict[str, Type[ElementBase]]] = {}¶
A mapping of the
plugin_attribvalues of registered plugins to their respective classes.
- plugin_multi_attrib: ClassVar[str] = 'fields'¶
For
ElementBasesubclasses that are intended to be an iterable group of items, theplugin_multi_attribvalue defines an interface for the parent stanza which returns the entire group of matching substanzas. So the following are equivalent:# Given stanza class Foo, with plugin_multi_attrib = 'foos' parent['foos'] filter(isinstance(item, Foo), parent['substanzas'])
- plugin_tag_map: ClassVar[Dict[str, Type[ElementBase]]] = {}¶
A mapping of root element tag names (in
'{namespace}elementname'format) to the plugin classes responsible for them.
- plugins: Dict[Tuple[str, Optional[str]], ElementBase]¶
An ordered dictionary of plugin stanzas, mapped by their
plugin_attribvalue.
- setAnswer(answer)¶
- setFalse()¶
- setOptions(options)¶
- setRequired(required)¶
- setTrue()¶
- setValue(value)¶
- setup(xml=None)[source]¶
Initialize the stanza’s XML contents.
Will return
Trueif XML was generated according to the stanza’s definition instead of building a stanza object from an existing XML object.- Parameters
xml – An existing XML object to use for the stanza’s content instead of generating new XML.
- sub_interfaces: ClassVar[Set[str]] = {'desc'}¶
A subset of
interfaceswhich maps interfaces to direct subelements of the underlying XML object. Using this set, the text of these subelements may be set, retrieved, or removed without needing to define custom methods.
- tag: str¶
The name of the tag for the stanza’s root element. It is the same as calling
tag_name()and is formatted as'{namespace}elementname'.
- true_values = {True, '1', 'true'}¶
- xml: ET.Element¶
The underlying XML object for the stanza. It is a standard
xml.etree.ElementTreeobject.
- class slixmpp.plugins.xep_0004.stanza.form.Form(*args, **kwargs)[source]¶
- addField(var='', ftype=None, label='', desc='', required=False, value=None, options=None, **kwargs)¶
- addReported(var, ftype=None, label='', desc='', **kwargs)¶
- add_field(var='', ftype=None, label='', desc='', required=False, value=None, options=None, **kwargs)[source]¶
- delFields()¶
- delInstructions()¶
- delReported()¶
- property field¶
- form_types = {'cancel', 'form', 'result', 'submit'}¶
- getFields(use_dict=False)¶
- getInstructions()¶
- getReported()¶
- getValues()¶
- interfaces: ClassVar[Set[str]] = OrderedSet(['instructions', 'reported', 'title', 'type', 'items', 'values'])¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attribvalue of any registered stanza plugins.
- iterables: List[ElementBase]¶
A list of child stanzas whose class is included in
plugin_iterables.
- loaded_plugins: Set[str]¶
- name: ClassVar[str] = 'x'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'jabber:x:data'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- parent: Optional[ReferenceType[ElementBase]]¶
A
weakref.weakrefto the parent stanza, if there is one. If not, thenparentisNone.
- plugin_attrib: ClassVar[str] = 'form'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- plugin_multi_attrib: ClassVar[str] = 'forms'¶
For
ElementBasesubclasses that are intended to be an iterable group of items, theplugin_multi_attribvalue defines an interface for the parent stanza which returns the entire group of matching substanzas. So the following are equivalent:# Given stanza class Foo, with plugin_multi_attrib = 'foos' parent['foos'] filter(isinstance(item, Foo), parent['substanzas'])
- plugins: Dict[Tuple[str, Optional[str]], ElementBase]¶
An ordered dictionary of plugin stanzas, mapped by their
plugin_attribvalue.
- setFields(fields)¶
- setInstructions(instructions)¶
- setReported(reported)¶
This either needs a dictionary of dictionaries or a dictionary of form fields. :param reported: :return:
- setValues(values)¶
- set_reported(reported)[source]¶
This either needs a dictionary of dictionaries or a dictionary of form fields. :param reported: :return:
- setup(xml=None)[source]¶
Initialize the stanza’s XML contents.
Will return
Trueif XML was generated according to the stanza’s definition instead of building a stanza object from an existing XML object.- Parameters
xml – An existing XML object to use for the stanza’s content instead of generating new XML.
- sub_interfaces: ClassVar[Set[str]] = {'title'}¶
A subset of
interfaceswhich maps interfaces to direct subelements of the underlying XML object. Using this set, the text of these subelements may be set, retrieved, or removed without needing to define custom methods.
- tag: str¶
The name of the tag for the stanza’s root element. It is the same as calling
tag_name()and is formatted as'{namespace}elementname'.
- xml: ET.Element¶
The underlying XML object for the stanza. It is a standard
xml.etree.ElementTreeobject.