XEP-0004: Data Forms#

class slixmpp.plugins.xep_0004.XEP_0004(xmpp, config=None)[source]#

XEP-0004: Data Forms

dependencies: ClassVar[Set[str]] = {'xep_0030'}#

Some plugins may depend on others in order to function properly. Any plugin names included in dependencies will be initialized as needed if this plugin is enabled.

description: str = 'XEP-0004: Data Forms'#

A longer name for the plugin, describing its purpose. For example, a plugin for XEP-0030 would use ‘Service Discovery’ as its description value.

name: str = 'xep_0004'#

A short name for the plugin based on the implemented specification. For example, a plugin for XEP-0030 would use ‘xep_0030’.

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_attrib value of any registered stanza plugins.

name: ClassVar[str] = 'option'#

The XML tag name of the element, not including any namespace prefixes. For example, an ElementBase object for <message /> would use name = 'message'.

namespace: str = 'jabber:x:data'#

The XML namespace for the element. Given <foo xmlns="bar" />, then namespace = "bar" should be used. The default namespace is jabber:client since this is being used in an XMPP library.

plugin_attrib: ClassVar[str] = 'option'#

For ElementBase subclasses which are intended to be used as plugins, the plugin_attrib value defines the plugin name. Plugins may be accessed by using the plugin_attrib value as the interface. An example using plugin_attrib = 'foo':

register_stanza_plugin(Message, FooPlugin)
msg = Message()
msg['foo']['an_interface_from_the_foo_plugin']
plugin_multi_attrib: ClassVar[str] = 'options'#

For ElementBase subclasses that are intended to be an iterable group of items, the plugin_multi_attrib value 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'])
sub_interfaces: ClassVar[Set[str]] = {'value'}#

A subset of interfaces which 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.

class slixmpp.plugins.xep_0004.stanza.field.FormField(xml=None, parent=None)[source]#
addOption(label='', value='')#
add_option(label='', value='')[source]#
delOptions()#
delRequired()#
delValue()#
del_options()[source]#
del_required()[source]#
del_value()[source]#
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)#
get_answer()[source]#
get_options()[source]#
get_required()[source]#
get_value(convert=True)[source]#
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_attrib value of any registered stanza plugins.

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 ElementBase object for <message /> would use name = 'message'.

namespace: str = 'jabber:x:data'#

The XML namespace for the element. Given <foo xmlns="bar" />, then namespace = "bar" should be used. The default namespace is jabber:client since this is being used in an XMPP library.

option_types = {'list-multi', 'list-single'}#
plugin_attrib: ClassVar[str] = 'field'#

For ElementBase subclasses which are intended to be used as plugins, the plugin_attrib value defines the plugin name. Plugins may be accessed by using the plugin_attrib value as the interface. An example using plugin_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_attrib values of registered plugins to their respective classes.

plugin_multi_attrib: ClassVar[str] = 'fields'#

For ElementBase subclasses that are intended to be an iterable group of items, the plugin_multi_attrib value 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.

setAnswer(answer)#
setFalse()#
setOptions(options)#
setRequired(required)#
setTrue()#
setValue(value)#
set_answer(answer)[source]#
set_false()[source]#
set_options(options)[source]#
set_required(required)[source]#
set_true()[source]#
set_type(value)[source]#
set_value(value)[source]#
setup(xml=None)[source]#

Initialize the stanza’s XML contents.

Will return True if 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 interfaces which 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.

true_values = {'1', 'true', True}#
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]#
add_item(values)[source]#
add_reported(var, ftype=None, label='', desc='', **kwargs)[source]#
cancel()[source]#
delFields()#
delInstructions()#
delReported()#
del_fields()[source]#
del_instructions()[source]#
del_items()[source]#
del_reported()[source]#
property field#
form_types = {'cancel', 'form', 'result', 'submit'}#
getFields(use_dict=False)#
getInstructions()#
getReported()#
getValues()#
get_fields(use_dict=False)[source]#
get_instructions()[source]#
get_items()[source]#
get_reported()[source]#
get_values()[source]#
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_attrib value of any registered stanza plugins.

merge(other)[source]#
name: ClassVar[str] = 'x'#

The XML tag name of the element, not including any namespace prefixes. For example, an ElementBase object for <message /> would use name = 'message'.

namespace: str = 'jabber:x:data'#

The XML namespace for the element. Given <foo xmlns="bar" />, then namespace = "bar" should be used. The default namespace is jabber:client since this is being used in an XMPP library.

plugin_attrib: ClassVar[str] = 'form'#

For ElementBase subclasses which are intended to be used as plugins, the plugin_attrib value defines the plugin name. Plugins may be accessed by using the plugin_attrib value as the interface. An example using plugin_attrib = 'foo':

register_stanza_plugin(Message, FooPlugin)
msg = Message()
msg['foo']['an_interface_from_the_foo_plugin']
plugin_multi_attrib: ClassVar[str] = 'forms'#

For ElementBase subclasses that are intended to be an iterable group of items, the plugin_multi_attrib value 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'])
reply()[source]#
setFields(fields)#
setInstructions(instructions)#
setReported(reported)#

This either needs a dictionary of dictionaries or a dictionary of form fields. :type reported: :param reported: :return:

setValues(values)#
set_fields(fields)[source]#
set_instructions(instructions)[source]#
set_items(items)[source]#
set_reported(reported)[source]#

This either needs a dictionary of dictionaries or a dictionary of form fields. :type reported: :param reported: :return:

set_type(ftype)[source]#
set_values(values)[source]#
setup(xml=None)[source]#

Initialize the stanza’s XML contents.

Will return True if 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 interfaces which 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.