# HG changeset patch # User Sylvain Thénault # Date 1287058245 -7200 # Node ID 70c87c717e4af8bfff57335927311d6f3786a6a2 # Parent 019ab5eb37ea6c7fefdddee90bafc40ffc2bd80c [config] make config.cubes() available on NoAppCubicWebConfiguration diff -r 019ab5eb37ea -r 70c87c717e4a cwconfig.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): diff -r 019ab5eb37ea -r 70c87c717e4a dbapi.py --- 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)