server/sources/datafeed.py
branchstable
changeset 8402 efafa1261477
parent 8069 4341fb713b14
child 8408 41461b2e9854
equal deleted inserted replaced
8398:a9fe30c953be 8402:efafa1261477
   369             if raise_on_error:
   369             if raise_on_error:
   370                 raise
   370                 raise
   371             self.import_log.record_error(str(ex))
   371             self.import_log.record_error(str(ex))
   372             return True
   372             return True
   373         error = False
   373         error = False
       
   374         # Check whether self._cw is a session or a connection
       
   375         if getattr(self._cw, 'commit', None) is not None:
       
   376             commit = self._cw.commit
       
   377             set_cnxset = self._cw.set_cnxset
       
   378             rollback = self._cw.rollback
       
   379         else:
       
   380             commit = self._cw.cnx.commit
       
   381             set_cnxset = lambda: None
       
   382             rollback = self._cw.cnx.rollback
   374         for args in parsed:
   383         for args in parsed:
   375             try:
   384             try:
   376                 self.process_item(*args)
   385                 self.process_item(*args)
   377                 if partialcommit:
   386                 if partialcommit:
   378                     # commit+set_cnxset instead of commit(free_cnxset=False) to let
   387                     # commit+set_cnxset instead of commit(free_cnxset=False) to let
   379                     # other a chance to get our connections set
   388                     # other a chance to get our connections set
   380                     self._cw.commit()
   389                     commit()
   381                     self._cw.set_cnxset()
   390                     set_cnxset()
   382             except ValidationError, exc:
   391             except ValidationError, exc:
   383                 if raise_on_error:
   392                 if raise_on_error:
   384                     raise
   393                     raise
   385                 if partialcommit:
   394                 if partialcommit:
   386                     self.source.error('Skipping %s because of validation error %s' % (args, exc))
   395                     self.source.error('Skipping %s because of validation error %s' % (args, exc))
   387                     self._cw.rollback()
   396                     rollback()
   388                     self._cw.set_cnxset()
   397                     set_cnxset()
   389                     error = True
   398                     error = True
   390                 else:
   399                 else:
   391                     raise
   400                     raise
   392         return error
   401         return error
   393 
   402