[dataimport] Add a ``flush`` method for all stores.
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Tue, 02 Apr 2013 12:12:41 +0200
changeset 8833 39f81e2db2fc
parent 8832 26cdfc6dd6f8
child 8834 6947201033be
[dataimport] Add a ``flush`` method for all stores. For ``ObjectStore``, ``RQLObjectStore`` and ``NoHookRQLObjectStore`` the method tries to call the ``commit`` method. For ``SQLGenObjectStore``, the ``flush`` method is basically unchanged with respect to previous changesets.
dataimport.py
--- a/dataimport.py	Tue Apr 02 12:11:44 2013 +0200
+++ b/dataimport.py	Tue Apr 02 12:12:41 2013 +0200
@@ -523,6 +523,18 @@
         """
         pass
 
+    def flush(self):
+        """The method is provided so that all stores share a common API.
+        It just tries to call the commit method.
+        """
+        print 'starting flush'
+        try:
+            self.commit()
+        except:
+            print 'failed to flush'
+        else:
+            print 'flush done'
+
     def rql(self, *args):
         if self._rql is not None:
             return self._rql(*args)
@@ -1010,6 +1022,8 @@
                                encoding=self.dbencoding)
         except:
             print 'failed to flush'
+        else:
+            print 'flush done'
         finally:
             _entities_sql.clear()
             _relations_sql.clear()