[auto-reload] we should never call load_module with use_sys=False, that may lead to inconsistency with module interdependancy (eg module get imported by another one, then is reimported by the vreg to load its appobjects. Cleanup of sys.modules done before reloading should be enough. stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 15 Jun 2010 18:00:26 +0200
branchstable
changeset 5748 487ab6ac90cc
parent 5747 d6ac0cd30fde
child 5749 b4393b681f7a
[auto-reload] we should never call load_module with use_sys=False, that may lead to inconsistency with module interdependancy (eg module get imported by another one, then is reimported by the vreg to load its appobjects. Cleanup of sys.modules done before reloading should be enough.
cwvreg.py
vregistry.py
--- a/cwvreg.py	Mon Jun 14 17:56:10 2010 +0200
+++ b/cwvreg.py	Tue Jun 15 18:00:26 2010 +0200
@@ -521,7 +521,7 @@
                     cpath = cfg.build_vregistry_cube_path([cfg.cube_dir(cube)])
                     cleanup_sys_modules(cpath)
         self.reset()
-        self.register_objects(path, force_reload)
+        self.register_objects(path)
         CW_EVENT_MANAGER.emit('after-registry-reload')
 
     def _set_schema(self, schema):
@@ -566,10 +566,11 @@
         if ifaces:
             self._needs_iface[obj] = ifaces
 
-    def register_objects(self, path, force_reload=False):
-        """overriden to remove objects requiring a missing interface"""
+    def register_objects(self, path):
+        """overriden to give cubicweb's extrapath (eg cubes package's __path__)
+        """
         super(CubicWebVRegistry, self).register_objects(
-            path, force_reload, self.config.extrapath)
+            path, self.config.extrapath)
 
     def initialization_completed(self):
         """cw specific code once vreg initialization is completed:
--- a/vregistry.py	Mon Jun 14 17:56:10 2010 +0200
+++ b/vregistry.py	Tue Jun 15 18:00:26 2010 +0200
@@ -413,11 +413,11 @@
         self._loadedmods = {}
         return filemods
 
-    def register_objects(self, path, force_reload=False, extrapath=None):
+    def register_objects(self, path, extrapath=None):
         # load views from each directory in the instance's path
         filemods = self.init_registration(path, extrapath)
         for filepath, modname in filemods:
-            self.load_file(filepath, modname, force_reload)
+            self.load_file(filepath, modname)
         self.initialization_completed()
 
     def initialization_completed(self):
@@ -455,7 +455,7 @@
                     return True
         return False
 
-    def load_file(self, filepath, modname, force_reload=False):
+    def load_file(self, filepath, modname):
         """load app objects from a python file"""
         from logilab.common.modutils import load_module_from_name
         if modname in self._loadedmods:
@@ -472,7 +472,7 @@
         # module
         self._lastmodifs[filepath] = mdate
         # load the module
-        module = load_module_from_name(modname, use_sys=not force_reload)
+        module = load_module_from_name(modname)
         self.load_module(module)
 
     def load_module(self, module):