From f74f4942d5e3fb1d791148aa07a75b5d474143cd Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Mon, 11 May 2015 21:17:57 -0400 Subject: [PATCH] DbDjango: method to checkpoint modules, to allow reloading Django --- gramps/webapp/modules_checkpoint.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 gramps/webapp/modules_checkpoint.py diff --git a/gramps/webapp/modules_checkpoint.py b/gramps/webapp/modules_checkpoint.py new file mode 100644 index 000000000..330138905 --- /dev/null +++ b/gramps/webapp/modules_checkpoint.py @@ -0,0 +1,13 @@ +import sys + +class ModulesCheckpoint(object): + def __init__(self): + self.original = sys.modules.copy() + + def reset(self): + # clear modules: + for key in list(sys.modules.keys()): + del(sys.modules[key]) + # load previous: + for key in self.original: + sys.modules[key] = self.original[key]