示例#1
0
def reload_django_settings():
        mod = util.import_module(os.environ['DJANGO_SETTINGS_MODULE'])

        # reload module
        reload(mod)

        # reload settings.
        # USe code from django.settings.Settings module.

        # Settings that should be converted into tuples if they're mistakenly entered
        # as strings.
        tuple_settings = ("INSTALLED_APPS", "TEMPLATE_DIRS")

        for setting in dir(mod):
            if setting == setting.upper():
                setting_value = getattr(mod, setting)
                if setting in tuple_settings and type(setting_value) == str:
                    setting_value = (setting_value,) # In case the user forgot the comma.
                setattr(settings, setting, setting_value)

        # Expand entries in INSTALLED_APPS like "django.contrib.*" to a list
        # of all those apps.
        new_installed_apps = []
        for app in settings.INSTALLED_APPS:
            if app.endswith('.*'):
                app_mod = util.import_module(app[:-2])
                appdir = os.path.dirname(app_mod.__file__)
                app_subdirs = os.listdir(appdir)
                name_pattern = re.compile(r'[a-zA-Z]\w*')
                for d in sorted(app_subdirs):
                    if (name_pattern.match(d) and
                            os.path.isdir(os.path.join(appdir, d))):
                        new_installed_apps.append('%s.%s' % (app[:-2], d))
            else:
                new_installed_apps.append(app)
        setattr(settings, "INSTALLED_APPS", new_installed_apps)

        if hasattr(time, 'tzset') and settings.TIME_ZONE:
            # When we can, attempt to validate the timezone. If we can't find
            # this file, no check happens and it's harmless.
            zoneinfo_root = '/usr/share/zoneinfo'
            if (os.path.exists(zoneinfo_root) and not
                    os.path.exists(os.path.join(zoneinfo_root,
                        *(settings.TIME_ZONE.split('/'))))):
                raise ValueError("Incorrect timezone setting: %s" %
                        settings.TIME_ZONE)
            # Move the time zone info into os.environ. See ticket #2315 for why
            # we don't do this unconditionally (breaks Windows).
            os.environ['TZ'] = settings.TIME_ZONE
            time.tzset()

        # Settings are configured, so we can set up the logger if required
        if getattr(settings, 'LOGGING_CONFIG', False):
            # First find the logging configuration function ...
            logging_config_path, logging_config_func_name = settings.LOGGING_CONFIG.rsplit('.', 1)
            logging_config_module = util.import_module(logging_config_path)
            logging_config_func = getattr(logging_config_module, logging_config_func_name)

            # ... then invoke it with the logging settings
            logging_config_func(settings.LOGGING)
示例#2
0
    def load(self):
        # set settings
        make_default_env(self.cfg)

        # load wsgi application and return it.
        mod = util.import_module("gunicorn.app.django_wsgi")
        return mod.make_wsgi_application()
示例#3
0
    def load(self):
        # set settings
        make_default_env(self.cfg)

        # load wsgi application and return it.
        mod = util.import_module("gunicorn.app.django_wsgi")
        return mod.make_wsgi_application()
示例#4
0
    def load(self):
        # chdir to the configured path before loading,
        # default is the current dir
        os.chdir(self.cfg.chdir)

        # set settings
        make_default_env(self.cfg)

        # load wsgi application and return it.
        mod = util.import_module("gunicorn.app.django_wsgi")
        return mod.make_wsgi_application()
    def load(self):
        # chdir to the configured path before loading,
        # default is the current dir
        os.chdir(self.cfg.chdir)

        # set settings
        make_default_env(self.cfg)

        # load wsgi application and return it.
        mod = util.import_module("gunicorn.app.django_wsgi")
        return mod.make_wsgi_application()
示例#6
0
 def get_config_from_module_name(self, module_name):
     return vars(util.import_module(module_name))
示例#7
0
 def get_config_from_module_name(self, module_name):
     return vars(util.import_module(module_name))
示例#8
0
 def get_config_from_module_name(self, module_name):
     return util.import_module(module_name).__dict__
示例#9
0
文件: base.py 项目: lebseu/VAMK-HELP
 def get_config_from_module_name(self, module_name):
     return util.import_module(module_name).__dict__