[devtools] pre_setup_database should take a connection object
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 30 May 2014 17:25:31 +0200
changeset 9788 47d356ee14d2
parent 9787 ae624d86c652
child 9789 4903a959604a
[devtools] pre_setup_database should take a connection object
devtools/__init__.py
--- a/devtools/__init__.py	Fri May 30 11:10:54 2014 +0200
+++ b/devtools/__init__.py	Fri May 30 17:25:31 2014 +0200
@@ -490,15 +490,9 @@
             self.restore_database(DEFAULT_EMPTY_DB_ID)
             repo = self.get_repo(startup=True)
             cnx = self.get_cnx()
-            session = repo._sessions[cnx.sessionid]
-            session.set_cnxset()
-            _commit = session.commit
-            def keep_cnxset_commit(free_cnxset=False):
-                _commit(free_cnxset=free_cnxset)
-            session.commit = keep_cnxset_commit
-            pre_setup_func(session, self.config)
-            session.commit()
-            cnx.close()
+            with cnx:
+                pre_setup_func(cnx, self.config)
+                cnx.commit()
         self.backup_database(test_db_id)