migration.py
branchstable
changeset 6217 e2aeb40d5983
parent 6187 348c7d93cda3
child 6219 803c1019138e
--- a/migration.py	Mon Sep 13 10:51:55 2010 +0200
+++ b/migration.py	Mon Sep 13 11:00:22 2010 +0200
@@ -122,6 +122,7 @@
                           'config': self.config,
                           'interactive_mode': interactive,
                           }
+        self._context_stack = []
 
     def __getattribute__(self, name):
         try:
@@ -284,6 +285,11 @@
                     context[attr[4:]] = getattr(self, attr)
         return context
 
+    def update_context(self, key, value):
+        for context in self._context_stack:
+            context[key] = value
+        self.__context[key] = value
+
     def cmd_process_script(self, migrscript, funcname=None, *args, **kwargs):
         """execute a migration script in interactive mode
 
@@ -327,6 +333,7 @@
         if not self.execscript_confirm(migrscript):
             return
         scriptlocals = self._create_context().copy()
+        self._context_stack.append(scriptlocals)
         if script_mode == 'python':
             if funcname is None:
                 pyname = '__main__'
@@ -352,6 +359,7 @@
             import doctest
             doctest.testfile(migrscript, module_relative=False,
                              optionflags=doctest.ELLIPSIS, globs=scriptlocals)
+        del self._context_stack[-1]
 
     def cmd_option_renamed(self, oldname, newname):
         """a configuration option has been renamed"""