DjangoDb: force load when write_version/create to make work with reset modules
This commit is contained in:
parent
cfb33ec1a2
commit
4805c3c7f0
@ -160,7 +160,7 @@ class DbState(Callback):
|
|||||||
|
|
||||||
## Work-around for databases that need sys refresh (django):
|
## Work-around for databases that need sys refresh (django):
|
||||||
def modules_is_set(self):
|
def modules_is_set(self):
|
||||||
LOG.warn("modules_is_set?")
|
LOG.info("modules_is_set?")
|
||||||
if hasattr(self, "_modules"):
|
if hasattr(self, "_modules"):
|
||||||
return self._modules != None
|
return self._modules != None
|
||||||
else:
|
else:
|
||||||
@ -168,7 +168,7 @@ class DbState(Callback):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def reset_modules(self):
|
def reset_modules(self):
|
||||||
LOG.warn("reset_modules!")
|
LOG.info("reset_modules!")
|
||||||
# First, clear out old modules:
|
# First, clear out old modules:
|
||||||
for key in list(sys.modules.keys()):
|
for key in list(sys.modules.keys()):
|
||||||
del(sys.modules[key])
|
del(sys.modules[key])
|
||||||
@ -177,6 +177,6 @@ class DbState(Callback):
|
|||||||
sys.modules[key] = self._modules[key]
|
sys.modules[key] = self._modules[key]
|
||||||
|
|
||||||
def save_modules(self):
|
def save_modules(self):
|
||||||
LOG.warn("save_modules!")
|
LOG.info("save_modules!")
|
||||||
self._modules = sys.modules.copy()
|
self._modules = sys.modules.copy()
|
||||||
|
|
||||||
|
@ -362,6 +362,7 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
force_bsddb_upgrade=False,
|
force_bsddb_upgrade=False,
|
||||||
force_bsddb_downgrade=False,
|
force_bsddb_downgrade=False,
|
||||||
force_python_upgrade=False):
|
force_python_upgrade=False):
|
||||||
|
_LOG.info("Django loading...")
|
||||||
self._directory = directory
|
self._directory = directory
|
||||||
self.full_name = os.path.abspath(self._directory)
|
self.full_name = os.path.abspath(self._directory)
|
||||||
self.path = self.full_name
|
self.path = self.full_name
|
||||||
@ -380,9 +381,11 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
return self.dictionary[item]
|
return self.dictionary[item]
|
||||||
|
|
||||||
|
_LOG.info("Django loading defaults from: " + directory)
|
||||||
try:
|
try:
|
||||||
settings.configure(Module(default_settings))
|
settings.configure(Module(default_settings))
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
|
_LOG.info("Django already configured error! Shouldn't happen!")
|
||||||
# already configured; ignore
|
# already configured; ignore
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -455,6 +458,7 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self.url_types = set()
|
self.url_types = set()
|
||||||
self.media_attributes = set()
|
self.media_attributes = set()
|
||||||
self.place_types = set()
|
self.place_types = set()
|
||||||
|
_LOG.info("Django loading... done!")
|
||||||
|
|
||||||
def prepare_import(self):
|
def prepare_import(self):
|
||||||
"""
|
"""
|
||||||
@ -2108,6 +2112,8 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
for filename in os.listdir(defaults):
|
for filename in os.listdir(defaults):
|
||||||
fullpath = os.path.abspath(os.path.join(defaults, filename))
|
fullpath = os.path.abspath(os.path.join(defaults, filename))
|
||||||
shutil.copy2(fullpath, directory)
|
shutil.copy2(fullpath, directory)
|
||||||
|
# force load, to get all modules loaded because of reset issue
|
||||||
|
self.load(directory)
|
||||||
|
|
||||||
def report_bm_change(self):
|
def report_bm_change(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user