sobjects/parsers.py
changeset 7001 c53aa19640b2
parent 6995 6efb5a5696bd
child 7002 29f085f6177b
--- a/sobjects/parsers.py	Wed Feb 16 10:30:09 2011 +0100
+++ b/sobjects/parsers.py	Thu Feb 17 10:24:45 2011 +0100
@@ -191,13 +191,25 @@
         # XXX suppression support according to source configuration. If set, get
         # all cwuri of entities from this source, and compare with newly
         # imported ones
+        error = False
         for item, rels in self.parse(url):
-            self.process_item(item, rels)
-            if partialcommit:
-                # commit+set_pool instead of commit(reset_pool=False) to let
-                # other a chance to get our pool
-                self._cw.commit()
-                self._cw.set_pool()
+            cwuri = item['cwuri']
+            try:
+                self.process_item(item, rels)
+                if partialcommit:
+                    # commit+set_pool instead of commit(reset_pool=False) to let
+                    # other a chance to get our pool
+                    self._cw.commit()
+                    self._cw.set_pool()
+            except ValidationError, exc:
+                if partialcommit:
+                    self.source.error('Skipping %s because of validation error %s' % (cwuri, exc))
+                    self._cw.rollback()
+                    self._cw.set_pool()
+                    error = True
+                else:
+                    raise
+        return error
 
     def parse(self, url):
         if not url.startswith('http'):