Changeset 6847 for main/waeup.sirp/trunk


Ignore:
Timestamp:
3 Oct 2011, 08:04:49 (13 years ago)
Author:
Henrik Bettermann
Message:

Define conversion checking method which can be customized by derived processors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/batching.py

    r6835 r6847  
    176176        """
    177177        for key, value in row.items():
    178             # Skip location and catalog fields used to locate the object
     178            # Skip fields not declared in interface.
    179179            if hasattr(obj, key):
    180180                setattr(obj, key, value)
     
    218218        return
    219219
     220    def checkConversion(self, row, mode='ignore'):
     221        """Validates all values in row.
     222        """
     223        converter = IObjectConverter(self.iface)
     224        errs, inv_errs, conv_dict =  converter.fromStringDict(
     225            row, self.factory_name)
     226        return errs, inv_errs, conv_dict
     227
    220228    def doImport(self, path, headerfields, mode='create', user='Unknown',
    221229                 logger=None):
     
    247255        num_warns = 0
    248256        site = grok.getSite()
    249         converter = IObjectConverter(self.iface)
     257       
    250258        for raw_row in reader:
    251259            num += 1
    252260            string_row = self.applyMapping(raw_row, mapping)
    253261            row = dict(string_row.items()) # create deep copy
    254             errs, inv_errs, conv_dict =  converter.fromStringDict(
    255                 string_row, self.factory_name)
     262            errs, inv_errs, conv_dict = self.checkConversion(string_row, mode)
    256263            if errs or inv_errs:
    257264                num_warns += 1
Note: See TracChangeset for help on using the changeset viewer.