Ignore:
Timestamp:
18 Apr 2012, 05:12:32 (13 years ago)
Author:
Henrik Bettermann
Message:

Empty If no value is provided in import files, attributes must not be cleared. Clear attribute only if value == DELETIONMARKER.

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

    r7950 r8202  
    3232from waeup.kofa.interfaces import (
    3333    IBatchProcessor, FatalCSVError, IObjectConverter,
    34     ICSVExporter)
     34    ICSVExporter, DELETIONMARKER)
    3535
    3636class BatchProcessor(grok.GlobalUtility):
     
    204204            # Skip fields not declared in interface.
    205205            if hasattr(obj, key):
    206                 setattr(obj, key, value)
     206                # Set attribute to None if value is marked for deletion
     207                if value == DELETIONMARKER:
     208                    setattr(obj, key, None)
     209                elif value is not None:
     210                    setattr(obj, key, value)
    207211        return
    208212
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_batching.py

    r7858 r8202  
    104104
    105105    def updateEntry(self, obj, row, site):
    106         # This is not strictly necessary, as the default
    107         # updateEntry method does exactly the same
    108106        for key, value in row.items():
    109             setattr(obj, key, value)
     107            if value is not None:
     108                setattr(obj, key, value)
    110109
    111110class BatchProcessorTests(FunctionalTestCase):
Note: See TracChangeset for help on using the changeset viewer.