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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r8176 r8202  
    3434from waeup.kofa.interfaces import (
    3535    IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount,
    36     IObjectHistory, VALIDATED)
     36    IObjectHistory, VALIDATED, DELETIONMARKER)
    3737from waeup.kofa.interfaces import MessageFactory as _
    3838from waeup.kofa.students.interfaces import (
     
    168168                history.addMessage(msg)
    169169            elif hasattr(obj, key):
    170                 setattr(obj, key, value)
     170                # Set attribute to None if value is marked for deletion
     171                if value == DELETIONMARKER:
     172                    setattr(obj, key, None)
     173                elif value is not None:
     174                    setattr(obj, key, value)
    171175            items_changed += '%s=%s, ' % (key,value)
    172176        parent = self.getParent(row, site)
     
    296300            # Skip fields not declared in interface.
    297301            if hasattr(obj, key):
    298                 setattr(obj, key, value)
    299                 if key == 'certificate':
    300                     value = value.code
     302                # Set attribute to None if value is marked for deletion
     303                if value == DELETIONMARKER:
     304                    setattr(obj, key, None)
     305                elif value is not None:
     306                    setattr(obj, key, value)
     307                    if key == 'certificate':
     308                        value = value.code
    301309            items_changed += '%s=%s, ' % (key,value)
    302310        parent = self.getParent(row, site)
     
    687695            if hasattr(obj, key) and not key in [
    688696                'current_session','current_level']:
    689                 setattr(obj, key, value)
     697                # Set attribute to None if value is marked for deletion
     698                if value == DELETIONMARKER:
     699                    setattr(obj, key, None)
     700                elif value is not None:
     701                    setattr(obj, key, value)
    690702            items_changed += '%s=%s, ' % (key,value)
    691703        parent = self.getParent(row, site)
Note: See TracChangeset for help on using the changeset viewer.