Changeset 13159 for main/waeup.kofa/trunk/src
- Timestamp:
- 10 Jul 2015, 11:33:03 (9 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/hostels/batching.py
r12883 r13159 68 68 """Update obj to the values given in row. 69 69 """ 70 changed = [] 71 for key, value in row.items(): 72 # Skip fields to be ignored. 73 if value == IGNORE_MARKER: 74 continue 75 if not hasattr(obj, key): 76 continue 77 try: 78 evalvalue = eval(value) 79 if isinstance(evalvalue, list): 80 value = evalvalue 81 except: 82 pass 83 setattr(obj, key, value) 84 log_value = getattr(value, 'code', value) 85 changed.append('%s=%s' % (key, log_value)) 86 70 items_changed = super(HostelProcessor, self).updateEntry( 71 obj, row, site, filename) 87 72 # Log actions... 88 73 location_field = self.location_fields[0] 89 items_changed = ', '.join(changed)90 74 grok.getSite()['hostels'].logger.info( 91 75 '%s - %s - %s - updated: %s' -
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.