[config] make config.cubes() available on NoAppCubicWebConfiguration
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 14 Oct 2010 14:10:45 +0200
changeset 6494 70c87c717e4a
parent 6493 019ab5eb37ea
child 6497 84fbd09f8c6b
[config] make config.cubes() available on NoAppCubicWebConfiguration
cwconfig.py
dbapi.py
--- a/cwconfig.py	Thu Oct 14 14:10:02 2010 +0200
+++ b/cwconfig.py	Thu Oct 14 14:10:45 2010 +0200
@@ -671,6 +671,7 @@
     def __init__(self, debugmode=False):
         register_stored_procedures()
         ConfigurationMixIn.__init__(self)
+        self._cubes = None
         self.debugmode = debugmode
         self.adjust_sys_path()
         self.load_defaults()
@@ -773,6 +774,31 @@
         """
         return None
 
+    _cubes = None
+
+    def init_cubes(self, cubes):
+        assert self._cubes is None, self._cubes
+        self._cubes = self.reorder_cubes(cubes)
+        # load cubes'__init__.py file first
+        for cube in cubes:
+            __import__('cubes.%s' % cube)
+        self.load_site_cubicweb()
+
+    def cubes(self):
+        """return the list of cubes used by this instance
+
+        result is ordered from the top level cubes to inner dependencies
+        cubes
+        """
+        assert self._cubes is not None, 'cubes not initialized'
+        return self._cubes
+
+    def cubes_path(self):
+        """return the list of path to cubes used by this instance, from outer
+        most to inner most cubes
+        """
+        return [self.cube_dir(p) for p in self.cubes()]
+
 
 class CubicWebConfiguration(CubicWebNoAppConfiguration):
     """base class for cubicweb server and web configurations"""
@@ -929,7 +955,6 @@
     def __init__(self, appid, debugmode=False):
         self.appid = appid
         CubicWebNoAppConfiguration.__init__(self, debugmode)
-        self._cubes = None
         self.load_file_configuration(self.main_config_file())
 
     def adjust_sys_path(self):
@@ -954,33 +979,13 @@
         return join(iddir, self.appid)
 
     def init_cubes(self, cubes):
-        assert self._cubes is None, self._cubes
-        self._cubes = self.reorder_cubes(cubes)
-        # load cubes'__init__.py file first
-        for cube in cubes:
-            __import__('cubes.%s' % cube)
-        self.load_site_cubicweb()
+        super(CubicWebConfiguration, self).init_cubes(cubes)
         # reload config file in cases options are defined in cubes __init__
         # or site_cubicweb files
         self.load_file_configuration(self.main_config_file())
         # configuration initialization hook
         self.load_configuration()
 
-    def cubes(self):
-        """return the list of cubes used by this instance
-
-        result is ordered from the top level cubes to inner dependencies
-        cubes
-        """
-        assert self._cubes is not None
-        return self._cubes
-
-    def cubes_path(self):
-        """return the list of path to cubes used by this instance, from outer
-        most to inner most cubes
-        """
-        return [self.cube_dir(p) for p in self.cubes()]
-
     def add_cubes(self, cubes):
         """add given cubes to the list of used cubes"""
         if not isinstance(cubes, list):
--- a/dbapi.py	Thu Oct 14 14:10:02 2010 +0200
+++ b/dbapi.py	Thu Oct 14 14:10:45 2010 +0200
@@ -532,9 +532,8 @@
             esubpath = list(subpath)
             esubpath.remove('views')
             esubpath.append(join('web', 'views'))
-        cubespath = [config.cube_dir(p) for p in cubes]
-        config.load_site_cubicweb(cubespath)
-        vpath = config.build_vregistry_path(reversed(cubespath),
+        config.init_cubes(cubes)
+        vpath = config.build_vregistry_path(reversed(config.cubes_path()),
                                             evobjpath=esubpath,
                                             tvobjpath=subpath)
         self.vreg.register_objects(vpath)