Ignore:
Timestamp:
30 May 2011, 07:15:54 (14 years ago)
Author:
Henrik Bettermann
Message:

Use DuplicationError? exception for batching (data import).

File:
1 edited

Legend:

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

    r6219 r6243  
    1515from zope.schema import getFields
    1616from waeup.sirp.interfaces import (
    17     IBatchProcessor, ISchemaTypeConverter, FatalCSVError)
     17    IBatchProcessor, ISchemaTypeConverter, FatalCSVError, DuplicationError)
    1818
    1919class BatchProcessor(grok.GlobalUtility):
     
    282282                    continue
    283283                obj = self.callFactory()
    284                 #import pdb; pdb.set_trace()
    285284                for key, value in row.items():
    286285                    setattr(obj, key, value)
    287                 if not self.addEntry(obj, row, site):
    288                     num_warns += 1
    289                     self.writeFailedRow(
    290                         failed_writer, raw_row,
    291                         "This object code already exists somewhere else. Skipping.")
     286                try:
     287                    self.addEntry(obj, row, site)
     288                except DuplicationError, error:
     289                    num_warns += 1
     290                    self.writeFailedRow(
     291                        failed_writer, raw_row,
     292                        "%s Skipping." % error.msg)
    292293                    continue
    293294            elif mode == 'remove':
Note: See TracChangeset for help on using the changeset viewer.