def _load_module(self, fullname): # TODO: is this needed? if fullname in sys.modules: return sys.modules[fullname] # pragma: no cover if self.default_settings: default_settings_mod = import_module(self.default_settings) else: default_settings_mod = None settings_mod = create_module(self.name) # Django doesn't play too nice without the config file living as a real file, so let's fake it. settings_mod.__file__ = self.config_path # install the default settings for this app load_settings(default_settings_mod, allow_extras=self.allow_extras, settings=settings_mod) # install the custom settings for this app load_settings(self.config_path, allow_extras=self.allow_extras, settings=settings_mod) if self.callback: self.callback(settings_mod) return settings_mod
def load_module(self, fullname): # TODO: is this needed? if fullname in sys.modules: return sys.modules[fullname] # pragma: no cover if self.default_settings: default_settings_mod = import_module(self.default_settings) else: default_settings_mod = None settings_mod = create_module(self.name) # Django doesn't play too nice without the config file living as a real file, so let's fake it. settings_mod.__file__ = self.config_path # install the default settings for this app load_settings(default_settings_mod, allow_extras=self.allow_extras, settings=settings_mod) # install the custom settings for this app load_settings(self.config_path, allow_extras=self.allow_extras, settings=settings_mod) if self.callback: self.callback(settings_mod) return settings_mod
def load_settings(mod_or_filename, silent=False, allow_extras=True, settings=django_settings): if isinstance(mod_or_filename, basestring): conf = create_module('temp_config', install=False) conf.__file__ = mod_or_filename try: execfile(mod_or_filename, conf.__dict__) except IOError as e: if silent and e.errno in (errno.ENOENT, errno.EISDIR): return settings e.strerror = 'Unable to load configuration file (%s)' % e.strerror raise else: conf = mod_or_filename add_settings(conf, allow_extras=allow_extras, settings=settings)