[repository] move modification of appobject_path to repository initialization code so we can restore it later to avoid side effect on the config. Fix regression introduced in d32ab8570e5d
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 05 Oct 2012 16:54:22 +0200
changeset 8580 d753d6a6798f
parent 8579 c4673bc11053
child 8581 ac3cbf55d9fb
[repository] move modification of appobject_path to repository initialization code so we can restore it later to avoid side effect on the config. Fix regression introduced in d32ab8570e5d
server/__init__.py
server/repository.py
--- a/server/__init__.py	Thu Oct 11 18:42:13 2012 +0200
+++ b/server/__init__.py	Fri Oct 05 16:54:22 2012 +0200
@@ -165,6 +165,8 @@
     # on connection
     config.creating = True
     config.consider_user_state = False
+    config.cubicweb_appobject_path = set(('hooks', 'entities'))
+    config.cube_appobject_path = set(('hooks', 'entities'))
     # only enable the system source at initialization time
     repo = Repository(config, vreg=vreg)
     schema = repo.schema
@@ -242,6 +244,9 @@
     # restore initial configuration
     config.creating = False
     config.consider_user_state = True
+    # (drop instance attribute to get back to class attribute)
+    del config.cubicweb_appobject_path
+    del config.cube_appobject_path
     print '-> database for instance %s initialized.' % config.appid
 
 
--- a/server/repository.py	Thu Oct 11 18:42:13 2012 +0200
+++ b/server/repository.py	Fri Oct 05 16:54:22 2012 +0200
@@ -223,19 +223,13 @@
             config['connections-pool-size'] = 1
             # will be reinitialized later from cubes found in the database
             config._cubes = None
-        elif config.creating:
-            # repository creation
-            config.bootstrap_cubes()
-            # trigger vreg initialisation of entity classes
-            config.cubicweb_appobject_path = set(('hooks', 'entities'))
-            config.cube_appobject_path = set(('hooks', 'entities'))
-            self.set_schema(config.load_schema())
         elif config.read_instance_schema:
             # normal start: load the instance schema from the database
             self.fill_schema()
         else:
-            # test start: use the file system schema (quicker)
-            self.warning("set fs instance'schema")
+            if not config.creating:
+                # test start: use the file system schema (quicker)
+                self.warning("set fs instance'schema")
             config.bootstrap_cubes()
             self.set_schema(config.load_schema())
         if not config.creating: