diff -r 51cc4b61f9ae -r 282194aa43f3 cwconfig.py --- a/cwconfig.py Mon Jun 21 15:32:58 2010 +0200 +++ b/cwconfig.py Mon Jun 21 15:34:46 2010 +0200 @@ -668,6 +668,7 @@ self.load_defaults() # will be properly initialized later by _gettext_init self.translations = {'en': (unicode, lambda ctx, msgid: unicode(msgid) )} + self._site_loaded = set() # don't register ReStructured Text directives by simple import, avoid pb # with eg sphinx. # XXX should be done properly with a function from cw.uicfg @@ -696,7 +697,7 @@ init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format, rotation_parameters={'when': 'W6', # every sunday 'interval': 1, - 'backupCount': 52,}) + 'backupCount': 52}) else: init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format) # configure simpleTal logger @@ -708,6 +709,34 @@ """ return [] + apphome = None + + def load_site_cubicweb(self, paths=None): + """load instance's specific site_cubicweb file""" + if paths is None: + paths = self.cubes_path() + if self.apphome is not None: + paths = [self.apphome] + paths + for path in reversed(paths): + sitefile = join(path, 'site_cubicweb.py') + if exists(sitefile) and not sitefile in self._site_loaded: + self._load_site_cubicweb(sitefile) + self._site_loaded.add(sitefile) + else: + sitefile = join(path, 'site_erudi.py') + if exists(sitefile) and not sitefile in self._site_loaded: + self._load_site_cubicweb(sitefile) + self._site_loaded.add(sitefile) + self.warning('[3.5] site_erudi.py is deprecated, should be ' + 'renamed to site_cubicweb.py') + + def _load_site_cubicweb(self, sitefile): + # XXX extrapath argument to load_module_from_file only in lgc > 0.50.2 + from logilab.common.modutils import load_module_from_modpath, modpath_from_file + module = load_module_from_modpath(modpath_from_file(sitefile, self.extrapath)) + self.info('%s loaded', sitefile) + return module + def eproperty_definitions(self): cfg = self.persistent_options_configuration() for section, options in cfg.options_by_section(): @@ -889,7 +918,6 @@ self.appid = appid CubicWebNoAppConfiguration.__init__(self, debugmode) self._cubes = None - self._site_loaded = set() self.load_file_configuration(self.main_config_file()) def adjust_sys_path(self): @@ -964,37 +992,6 @@ infos.append('%s-%s' % (pkg, version)) return md5.new(';'.join(infos)).hexdigest() - def load_site_cubicweb(self): - """load instance's specific site_cubicweb file""" - paths = self.cubes_path() - if self.apphome is not None: - paths = [self.apphome] + paths - for path in reversed(paths): - sitefile = join(path, 'site_cubicweb.py') - if exists(sitefile) and not sitefile in self._site_loaded: - self._load_site_cubicweb(sitefile) - self._site_loaded.add(sitefile) - else: - sitefile = join(path, 'site_erudi.py') - if exists(sitefile) and not sitefile in self._site_loaded: - self._load_site_cubicweb(sitefile) - self._site_loaded.add(sitefile) - self.warning('[3.5] site_erudi.py is deprecated, should be ' - 'renamed to site_cubicweb.py') - - def _load_site_cubicweb(self, sitefile): - # XXX extrapath argument to load_module_from_file only in lgc > 0.46 - from logilab.common.modutils import load_module_from_modpath, modpath_from_file - def load_module_from_file(filepath, path=None, use_sys=1, extrapath=None): - return load_module_from_modpath(modpath_from_file(filepath, extrapath), - path, use_sys) - module = load_module_from_file(sitefile, extrapath=self.extrapath) - self.info('%s loaded', sitefile) - # cube specific options - if getattr(module, 'options', None): - self.register_options(module.options) - self.load_defaults() - def load_configuration(self): """load instance's configuration files""" super(CubicWebConfiguration, self).load_configuration() @@ -1002,6 +999,13 @@ # init gettext self._gettext_init() + def _load_site_cubicweb(self, sitefile): + # overriden to register cube specific options + mod = super(CubicWebConfiguration, self)._load_site_cubicweb(sitefile) + if getattr(mod, 'options', None): + self.register_options(module.options) + self.load_defaults() + def init_log(self, logthreshold=None, force=False): """init the log service""" if not force and hasattr(self, '_logging_initialized'): @@ -1096,7 +1100,8 @@ SMTP_LOCK.release() return True -set_log_methods(CubicWebConfiguration, logging.getLogger('cubicweb.configuration')) +set_log_methods(CubicWebNoAppConfiguration, + logging.getLogger('cubicweb.configuration')) # alias to get a configuration instance from an instance id instance_configuration = CubicWebConfiguration.config_for