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

Use DuplicationError? exception for batching (data import).

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r6235 r6243  
    13251325            entries = error.entries
    13261326            for entry in entries:
    1327                 # show links to all certs with same code
     1327                # do not use error.msg but render a more detailed message instead
     1328                # and show links to all certs with same code
    13281329                message = 'A certificate with same code already exists: '
    13291330                message += '<a href="%s">%s</a>' % (
  • main/waeup.sirp/trunk/src/waeup/sirp/university/batching.py

    r6219 r6243  
    186186    def addEntry(self, obj, row, site):
    187187        parent = self.getParent(row, site)
    188         message = parent.addCertificate(obj)
    189         if not message == 'Certificate added.':
    190             return False
    191         return True
     188        parent.addCertificate(obj)
     189        return
    192190
    193191    def delEntry(self, row, site):
  • main/waeup.sirp/trunk/src/waeup/sirp/university/certificatecontainer.py

    r6242 r6243  
    6565            if len(entries) > 0:
    6666                raise DuplicationError(
    67                     'Certificate exists already elsewhere', entries)
     67                    'Certificate exists already elsewhere.', entries)
    6868        else:
    6969            # No catalog, then this addition won't do harm to anything.
  • 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.