DbDjango: method to checkpoint modules, to allow reloading Django

This commit is contained in:
Doug Blank 2015-05-11 21:17:57 -04:00
parent b615fcb93c
commit f74f4942d5

View File

@ -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]