--- a/cwvreg.py Mon Aug 10 18:01:46 2009 +0200
+++ b/cwvreg.py Tue Aug 11 12:20:13 2009 +0200
@@ -250,8 +250,8 @@
def itervalues(self):
return (value for key, value in self.items())
- def reset(self):
- super(CubicWebVRegistry, self).reset()
+ def reset(self, path=None, force_reload=None):
+ super(CubicWebVRegistry, self).reset(path, force_reload)
self._needs_iface = {}
# two special registries, propertydefs which care all the property
# definitions, and propertyvals which contains values for those
@@ -260,6 +260,17 @@
self['propertyvalues'] = self.eprop_values = {}
for key, propdef in self.config.eproperty_definitions():
self.register_property(key, **propdef)
+ if path is not None and force_reload:
+ cleanup_sys_modules(path)
+ cubes = self.config.cubes()
+ # if the fs code use some cubes not yet registered into the instance
+ # we should cleanup sys.modules for those as well to avoid potential
+ # bad class reference pb after reloading
+ cfg = self.config
+ for cube in cfg.expand_cubes(cubes, with_recommends=True):
+ if not cube in cubes:
+ cpath = cfg.build_vregistry_cube_path([cfg.cube_dir(cube)])
+ cleanup_sys_modules(cpath)
def set_schema(self, schema):
"""set instance'schema and load application objects"""
@@ -302,13 +313,14 @@
def register_objects(self, path, force_reload=None):
"""overriden to remove objects requiring a missing interface"""
+ if force_reload is None:
+ force_reload = self.config.mode == 'dev'
try:
self._register_objects(path, force_reload)
except RegistryOutOfDate:
CW_EVENT_MANAGER.emit('before-registry-reload')
# modification detected, reset and reload
- self.reset()
- cleanup_sys_modules(path)
+ self.reset(path, force_reload)
self._register_objects(path, force_reload)
CW_EVENT_MANAGER.emit('after-registry-reload')