# HG changeset patch # User Sylvain Thénault # Date 1244040744 -7200 # Node ID 010a4b0fe855e4be0f28a929ba408c4a0a09cee3 # Parent f190b66812735ed4116d0ffdb586e69e3b5c0ec1 fix lookup of files to load when using CW_CUBES_PATH diff -r f190b6681273 -r 010a4b0fe855 cwvreg.py --- a/cwvreg.py Wed Jun 03 09:15:20 2009 +0200 +++ b/cwvreg.py Wed Jun 03 16:52:24 2009 +0200 @@ -114,7 +114,12 @@ def register_objects(self, path, force_reload=None): """overriden to remove objects requiring a missing interface""" - if super(CubicWebRegistry, self).register_objects(path, force_reload): + extrapath = {} + for cubesdir in self.config.cubes_search_path(): + if cubesdir != self.config.CUBES_DIR: + extrapath[cubesdir] = 'cubes' + if super(CubicWebRegistry, self).register_objects(path, force_reload, + extrapath): self.initialization_completed() # call vreg_initialization_completed on appobjects and print # registry content diff -r f190b6681273 -r 010a4b0fe855 vregistry.py --- a/vregistry.py Wed Jun 03 09:15:20 2009 +0200 +++ b/vregistry.py Wed Jun 03 16:52:24 2009 +0200 @@ -31,19 +31,20 @@ from cubicweb import RegistryNotFound, ObjectNotFound, NoSelectableObject -def _toload_info(path, _toload=None): +def _toload_info(path, extrapath, _toload=None): """return a dictionary of : and an ordered list of (file, module name) to load """ from logilab.common.modutils import modpath_from_file if _toload is None: + assert isinstance(path, list) _toload = {}, [] for fileordir in path: if isdir(fileordir) and exists(join(fileordir, '__init__.py')): subfiles = [join(fileordir, fname) for fname in listdir(fileordir)] - _toload_info(subfiles, _toload) + _toload_info(subfiles, extrapath, _toload) elif fileordir[-3:] == '.py': - modname = '.'.join(modpath_from_file(fileordir)) + modname = '.'.join(modpath_from_file(fileordir, extrapath)) _toload[0][modname] = fileordir _toload[1].append((fileordir, modname)) return _toload @@ -313,13 +314,13 @@ # intialization methods ################################################### - def init_registration(self, path): + def init_registration(self, path, extrapath): # compute list of all modules that have to be loaded - self._toloadmods, filemods = _toload_info(path) + self._toloadmods, filemods = _toload_info(path, extrapath) self._loadedmods = {} return filemods - def register_objects(self, path, force_reload=None): + def register_objects(self, path, force_reload=None, extrapath=None): if force_reload is None: force_reload = self.config.mode == 'dev' elif not force_reload: @@ -339,7 +340,7 @@ if CW_SOFTWARE_ROOT in sys.path: sys.path.remove(CW_SOFTWARE_ROOT) # load views from each directory in the application's path - filemods = self.init_registration(path) + filemods = self.init_registration(path, extrapath) change = False for filepath, modname in filemods: if self.load_file(filepath, modname, force_reload):