devtools/__init__.py
changeset 9788 47d356ee14d2
parent 9679 a3a516cf8624
child 9789 4903a959604a
--- 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)