[check integrity] use session consistently
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 20 Sep 2012 16:33:51 +0200
changeset 8578 f6ea4ea63d57
parent 8577 3f082de68802
child 8579 c4673bc11053
[check integrity] use session consistently
server/checkintegrity.py
server/test/unittest_checkintegrity.py
--- a/server/checkintegrity.py	Thu Sep 20 16:18:13 2012 +0200
+++ b/server/checkintegrity.py	Thu Sep 20 16:33:51 2012 +0200
@@ -398,13 +398,13 @@
                 check_func = globals()['check_%s' % check]
                 check_func(repo.schema, session, eids_cache, fix=fix)
         if fix:
-            cnx.commit()
+            session.commit()
         else:
             print
         if not fix:
             print 'WARNING: Diagnostic run, nothing has been corrected'
     if reindex:
-        cnx.rollback()
+        session.rollback()
         session.set_cnxset()
         reindex_entities(repo.schema, session, withpb=withpb)
-        cnx.commit()
+        session.commit()
--- a/server/test/unittest_checkintegrity.py	Thu Sep 20 16:18:13 2012 +0200
+++ b/server/test/unittest_checkintegrity.py	Thu Sep 20 16:33:51 2012 +0200
@@ -29,8 +29,9 @@
         handler = get_test_db_handler(TestServerConfiguration(apphome=self.datadir))
         handler.build_db_cache()
         self.repo, self.cnx = handler.get_repo_and_cnx()
-        self.execute = self.cnx.cursor().execute
-        self.session = self.repo._sessions[self.cnx.sessionid]
+        session = self.repo._get_session(self.cnx.sessionid, setcnxset=True)
+        self.session = session
+        self.execute = session.execute
         sys.stderr = sys.stdout = StringIO()
 
     def tearDown(self):