fix cw properties initialization stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 18 Aug 2009 17:10:50 +0200
branchstable
changeset 2906 677fa98659a8
parent 2905 b23bbb31368c
child 2907 e222fac3cca3
fix cw properties initialization
cwvreg.py
vregistry.py
--- a/cwvreg.py	Tue Aug 18 17:10:08 2009 +0200
+++ b/cwvreg.py	Tue Aug 18 17:10:50 2009 +0200
@@ -228,8 +228,8 @@
             config.init_log(debug=debug)
         super(CubicWebVRegistry, self).__init__(config)
         self.schema = None
+        self.initialized = False
         self.reset()
-        self.initialized = False
 
     def setdefault(self, regid):
         try:
@@ -256,10 +256,11 @@
         # two special registries, propertydefs which care all the property
         # definitions, and propertyvals which contains values for those
         # properties
-        self['propertydefs'] = {}
-        self['propertyvalues'] = self.eprop_values = {}
-        for key, propdef in self.config.eproperty_definitions():
-            self.register_property(key, **propdef)
+        if not self.initialized:
+            self['propertydefs'] = {}
+            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()
--- a/vregistry.py	Tue Aug 18 17:10:08 2009 +0200
+++ b/vregistry.py	Tue Aug 18 17:10:50 2009 +0200
@@ -207,7 +207,9 @@
         self.config = config
 
     def reset(self, path=None, force_reload=None):
-        self.clear()
+        # don't use self.clear, we want to keep existing subdictionaries
+        for subdict in self.itervalues():
+            subdict.clear()
         self._lastmodifs = {}
 
     def __getitem__(self, name):