Changeset 13159 for main/waeup.kofa/trunk/src/waeup/kofa/utils
- Timestamp:
- 10 Jul 2015, 11:33:03 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py
r12997 r13159 221 221 if not hasattr(obj, key): 222 222 continue 223 # DefaultObjectConverter.fromStringDict fails for 224 # list-of-choices fields because we are using a different 225 # widget for this combination. Thus the ListFieldConverter 226 # returns a useless dictionary which causes getWidgetsData to 227 # skip the field. The value in row remains unchanged. 228 # We have to evaluate the string and replace the value here. 229 try: 230 evalvalue = eval(value) 231 if isinstance(evalvalue, list): 232 value = evalvalue 233 except: 234 pass 223 235 try: 224 236 setattr(obj, key, value) -
main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_converters.py
r8216 r13159 98 98 default = [], 99 99 ) 100 fav_colors = schema.List( 101 title = u'Favourite colors', 102 value_type = schema.Choice( 103 vocabulary = colors 104 ), 105 required = True, 106 default = [], 107 ) 100 108 friends = schema.List( 101 109 title = u'Friends', … … 405 413 return 406 414 415 def test_list_of_choices(self): 416 # We cannot handle lists of choices because we are using 417 # a widget which is not yet supported. 418 converter = IObjectConverter(IContact) 419 err, inv_err, data = converter.fromStringDict( 420 {"fav_colors": "['red', 'green']"}, 'contact') 421 self.assertEqual( 422 data, {}) 423 return 424 407 425 def test_ignore_values(self): 408 426 # in update mode we ignore marked values
Note: See TracChangeset for help on using the changeset viewer.