summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0004/stanza/form.py
diff options
context:
space:
mode:
authorRobert Robinson <rerobins@gmail.com>2015-09-14 14:31:17 -0600
committerRobert Robinson <rerobins@gmail.com>2015-09-14 16:46:36 -0600
commit0724f623bb613007f9acd6540efd4f256c8b6503 (patch)
tree1b82d65e7f46656b067ddbfb536e0dac8c430036 /sleekxmpp/plugins/xep_0004/stanza/form.py
parentbb094cc6498838cece046d9ed74881232fb5010d (diff)
downloadslixmpp-0724f623bb613007f9acd6540efd4f256c8b6503.tar.gz
slixmpp-0724f623bb613007f9acd6540efd4f256c8b6503.tar.bz2
slixmpp-0724f623bb613007f9acd6540efd4f256c8b6503.tar.xz
slixmpp-0724f623bb613007f9acd6540efd4f256c8b6503.zip
Force forms and fields to use plugin resolution
Instead of using the interface/subinterface code that was currently being implemented for the plugin. (cherry picked from commit 1467ec7)
Diffstat (limited to 'sleekxmpp/plugins/xep_0004/stanza/form.py')
-rw-r--r--sleekxmpp/plugins/xep_0004/stanza/form.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/sleekxmpp/plugins/xep_0004/stanza/form.py b/sleekxmpp/plugins/xep_0004/stanza/form.py
index 1d733760..cca9d2e0 100644
--- a/sleekxmpp/plugins/xep_0004/stanza/form.py
+++ b/sleekxmpp/plugins/xep_0004/stanza/form.py
@@ -22,8 +22,8 @@ class Form(ElementBase):
namespace = 'jabber:x:data'
name = 'x'
plugin_attrib = 'form'
- interfaces = set(('fields', 'instructions', 'items',
- 'reported', 'title', 'type', 'values'))
+ interfaces = set(('instructions', 'items',
+ 'reported', 'title', 'type', ))
sub_interfaces = set(('title',))
form_types = set(('cancel', 'form', 'result', 'submit'))
@@ -48,7 +48,7 @@ class Form(ElementBase):
def set_type(self, ftype):
self._set_attr('type', ftype)
if ftype == 'submit':
- fields = self['fields']
+ fields = self.get_fields()
for var in fields:
field = fields[var]
del field['type']
@@ -74,7 +74,8 @@ class Form(ElementBase):
field['desc'] = desc
field['required'] = required
if options is not None:
- field['options'] = options
+ for option in options:
+ field.add_option(**option)
else:
del field['type']
self.append(field)
@@ -227,9 +228,9 @@ class Form(ElementBase):
def set_values(self, values):
fields = self['fields']
for field in values:
- if field not in fields:
+ if field not in self.get_fields():
fields[field] = self.add_field(var=field)
- fields[field]['value'] = values[field]
+ self.get_fields()[field]['value'] = values[field]
def merge(self, other):
new = copy.copy(self)