From 8dbf53594bc9ea0aec1ecd81092d806d001a7b6c Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Tue, 27 Oct 2009 01:05:30 +0000 Subject: * fixed bug with setting boolean values in forms * added setValues to forms --- sleekxmpp/plugins/xep_0004.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/plugins') diff --git a/sleekxmpp/plugins/xep_0004.py b/sleekxmpp/plugins/xep_0004.py index 62587db6..faee631c 100644 --- a/sleekxmpp/plugins/xep_0004.py +++ b/sleekxmpp/plugins/xep_0004.py @@ -104,7 +104,7 @@ class Form(FieldContainer): else: form1.field[field.var].value = field.value for option, label in field.options: - if (option, label) not in form1.fields[field.var].options: + if (option, label) not in form1.field[field.var].options: form1.fields[field.var].addOption(option, label) return form1 @@ -123,6 +123,15 @@ class Form(FieldContainer): result[field.var] = value return result + def setValues(self, values={}): + for field in values: + if field in self.field: + if isintance(values[field], list) or isinstance(values[field], tuple): + for value in values[field]: + self.field[field].setValue(value) + else: + self.field[field].setValue(values[field]) + def fromXML(self, xml): self.buildForm(xml) -- cgit v1.2.3