Changeset 22:bb77a1005b63 in ralphm-patches
- Timestamp:
- Dec 31, 2009, 2:39:14 PM (12 years ago)
- Branch:
- default
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pubsub-forms.patch
r21 r22 1 diff -r 2ad7e6f72b63 -r 438b64816faawokkel/data_form.py2 --- a/wokkel/data_form.py Wed Dec 30 21:16:042009 +01003 +++ b/wokkel/data_form.py Wed Dec 30 21:22:362009 +01001 diff -r 5ccaacff8028 wokkel/data_form.py 2 --- a/wokkel/data_form.py Thu Dec 31 14:34:48 2009 +0100 3 +++ b/wokkel/data_form.py Thu Dec 31 14:36:22 2009 +0100 4 4 @@ -76,6 +76,7 @@ 5 5 option['label'] = self.label … … 59 59 kwargs['options'] = options 60 60 61 @@ -343,7 +345,7 @@ 62 """ 63 Data Form. 64 65 - There are two similarly named properties of forms. The L{formType} is the 66 + There are two similarly named properties of forms. The C{formType} is the 67 the so-called type of the form, and is set as the C{'type'} attribute 68 on the form's root element. 69 70 @@ -351,19 +353,25 @@ 71 provide a context for the field names used in this form, by setting a 72 special hidden field named C{'FORM_TYPE'}, to put the names of all 73 other fields in the namespace of the value of that field. This namespace 74 - is recorded in the L{formNamespace} instance variable. 75 + is recorded in the C{formNamespace} instance variable. 76 77 @ivar formType: Type of form. One of C{'form'}, C{'submit'}, {'cancel'}, 78 or {'result'}. 79 - @type formType: C{str}. 80 + @type formType: C{str} 81 + 82 @ivar formNamespace: The optional namespace of the field names for this 83 - form. This goes in the special field named 84 - C{'FORM_TYPE'}, if set. 85 - @type formNamespace: C{str}. 86 - @ivar fields: Dictionary of fields that have a name. Note that this is 87 - meant to be used for reading, only. One should use 88 - L{addField} for adding fields. 89 + form. This goes in the special field named C{'FORM_TYPE'}, if set. 90 + @type formNamespace: C{str} 91 + 92 + @ivar fields: Dictionary of named fields. Note that this is meant to be 93 + used for reading, only. One should use L{addField} or L{makeFields} and 94 + L{removeField} for adding and removing fields. 95 @type fields: C{dict} 96 + 97 + @ivar fieldList: List of all fields, in the order they are added. Like 98 + C{fields}, this is meant to be used for reading, only. 99 + @type fieldList: C{list} 100 + 101 """ 102 103 def __init__(self, formType, title=None, instructions=None, 104 @@ -403,7 +411,7 @@ 61 @@ -415,7 +417,7 @@ 105 62 """ 106 63 Add a field to this form. … … 111 68 adding new fields. Multiple fields with the same name are disallowed. 112 69 """ 113 @@ -4 16,7 +424,71 @@70 @@ -428,7 +430,71 @@ 114 71 self.fieldList.append(field) 115 72 … … 183 140 form['type'] = self.formType 184 141 185 @@ -4 77,7 +549,17 @@142 @@ -489,7 +555,17 @@ 186 143 187 144 return form … … 201 158 202 159 for name, field in self.fields.iteritems(): 203 @@ - 489,3 +571,48 @@160 @@ -501,3 +577,48 @@ 204 161 values[name] = value 205 162 … … 250 207 + for field in filtered: 251 208 + self.removeField(field) 252 diff -r 2ad7e6f72b63 -r 438b64816faawokkel/pubsub.py253 --- a/wokkel/pubsub.py Wed Dec 30 21:16:042009 +0100254 +++ b/wokkel/pubsub.py Wed Dec 30 21:22:362009 +0100209 diff -r 5ccaacff8028 wokkel/pubsub.py 210 --- a/wokkel/pubsub.py Thu Dec 31 14:34:48 2009 +0100 211 +++ b/wokkel/pubsub.py Thu Dec 31 14:36:22 2009 +0100 255 212 @@ -1012,29 +1012,11 @@ 256 213 return None … … 286 243 287 244 245 diff -r 5ccaacff8028 wokkel/test/test_data_form.py 246 --- a/wokkel/test/test_data_form.py Thu Dec 31 14:34:48 2009 +0100 247 +++ b/wokkel/test/test_data_form.py Thu Dec 31 14:36:22 2009 +0100 248 @@ -544,3 +544,42 @@ 249 field2 = data_form.Field(var='test', value='value2') 250 form.addField(field1) 251 self.assertRaises(data_form.Error, form.addField, field2) 252 + 253 + 254 + def test_removeField(self): 255 + """ 256 + A removed field should not occur in fieldList. 257 + """ 258 + form = data_form.Form('result') 259 + field = data_form.Field('fixed', value='Section 1') 260 + form.addField(field) 261 + form.removeField(field) 262 + self.assertNotIn(field, form.fieldList) 263 + 264 + 265 + def test_removeFieldNamed(self): 266 + """ 267 + A removed named field should not occur in fields. 268 + """ 269 + form = data_form.Form('result') 270 + field = data_form.Field(var='test', value='test1') 271 + form.addField(field) 272 + form.removeField(field) 273 + self.assertNotIn('test', form.fields) 274 + 275 + 276 + def test_makeFieldsJID(self): 277 + values = {'pubsub#creator': jid.JID('user@example.org')} 278 + form = data_form.Form('result') 279 + form.makeFields(values) 280 + field = form.fields['pubsub#creator'] 281 + self.assertEqual('jid-single', field.fieldType) 282 + 283 + 284 + def test_makeFieldsJIDMulti(self): 285 + values = {'pubsub#contact': [jid.JID('user@example.org'), 286 + jid.JID('other@example.org')]} 287 + form = data_form.Form('result') 288 + form.makeFields(values) 289 + field = form.fields['pubsub#contact'] 290 + self.assertEqual('jid-multi', field.fieldType) -
series
r21 r22 1 form-missing-tests.patch 1 2 pubsub-forms.patch 2 3 pubsub-request-options-form.patch
Note: See TracChangeset
for help on using the changeset viewer.