[datafeed] do NOT call commit in DataFeedXMLParser.process() (closes #10928592)
authorDavid Douard <david.douard@logilab.fr>
Fri, 19 Feb 2016 11:03:32 +0100
changeset 11147 ddd5dbf52b72
parent 11146 517e7cdd7b1b
child 11148 244e30f18720
[datafeed] do NOT call commit in DataFeedXMLParser.process() (closes #10928592) and so, remove more useless code. Doing a commit in DataFeedXMLParser.process() is a bad idea because this method is called for every imported/updated entity, before handling deletions. So if we commit here, odds are quite high that we're violating some integrity constraint and end up with a ValidationError.
server/sources/datafeed.py
--- a/server/sources/datafeed.py	Wed Feb 17 14:00:39 2016 +0100
+++ b/server/sources/datafeed.py	Fri Feb 19 11:03:32 2016 +0100
@@ -493,23 +493,9 @@
                 raise
             self.import_log.record_error(str(ex))
             return True
-        error = False
-        commit = self._cw.commit
-        rollback = self._cw.rollback
         for args in parsed:
-            try:
-                self.process_item(*args, raise_on_error=raise_on_error)
-                # commit+set_cnxset instead of commit(free_cnxset=False) to let
-                # other a chance to get our connections set
-                commit()
-            except ValidationError as exc:
-                if raise_on_error:
-                    raise
-                self.source.error('Skipping %s because of validation error %s'
-                                  % (args, exc))
-                rollback()
-                error = True
-        return error
+            self.process_item(*args, raise_on_error=raise_on_error)
+        return False
 
     def parse(self, url):
         stream = self.retrieve_url(url)