[migration] set a cnxset before process_script()
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 18 Apr 2014 14:25:36 +0200
changeset 9686 9a04e48e780b
parent 9685 0033aa71e077
child 9687 00c2356faba7
[migration] set a cnxset before process_script() Not pretty, but I don't have a better idea right now and this at least ensures migration scripts get run in the expected environment and can access sql stuff as before.
server/migractions.py
--- a/server/migractions.py	Thu Apr 10 11:04:13 2014 +0200
+++ b/server/migractions.py	Fri Apr 18 14:25:36 2014 +0200
@@ -179,14 +179,15 @@
             super(ServerMigrationHelper, self).migrate(vcconf, toupgrade, options)
 
     def cmd_process_script(self, migrscript, funcname=None, *args, **kwargs):
-        try:
-            return super(ServerMigrationHelper, self).cmd_process_script(
-                  migrscript, funcname, *args, **kwargs)
-        except ExecutionError as err:
-            sys.stderr.write("-> %s\n" % err)
-        except BaseException:
-            self.rollback()
-            raise
+        with self.cnx._cnx.ensure_cnx_set:
+            try:
+                return super(ServerMigrationHelper, self).cmd_process_script(
+                      migrscript, funcname, *args, **kwargs)
+            except ExecutionError as err:
+                sys.stderr.write("-> %s\n" % err)
+            except BaseException:
+                self.rollback()
+                raise
 
     # Adjust docstring
     cmd_process_script.__doc__ = MigrationHelper.cmd_process_script.__doc__