Пример #1
0
    def load(cls, config_path):
        logger.debug("Load configuration file %s" % config_path)
        cls.__instance = None
        config = cls()
        config._config_path = config_path

        # Читаем настройки

        if not os.path.exists(config_path):
            raise ImproperlyConfigured(
                "Configuration file `%s` does not exist!" % config_path)

        document_tree = _helpers.load_xml(config_path)
        cls.validate(document_tree)

        config._document = document_tree.getroot()

        # Посчитаем хеш-сумму файла конфигурации, и запишем её в кэш django
        with open(config_path, "rb") as fd:
            config._hash = hashlib.md5(fd.read()).hexdigest()

        cache = _helpers.get_cache("wsfactory")
        cache.set(cls.CACHE_KEY, config._hash)
        config._configured = True

        logger.debug("Configuration file %s successfully loaded" % config_path)
Пример #2
0
    def load(cls, config_path):
        logger.debug("Load configuration file %s" % config_path)
        cls.__instance = None
        config = cls()
        config._config_path = config_path

        # Читаем настройки

        if not os.path.exists(config_path):
            raise ImproperlyConfigured(
                "Configuration file `%s` does not exist!" % config_path)

        document_tree = _helpers.load_xml(config_path)
        cls.validate(document_tree)

        config._document = document_tree.getroot()

        # Посчитаем хеш-сумму файла конфигурации, и запишем её в кэш django
        with open(config_path, "rb") as fd:
            config._hash = hashlib.md5(fd.read()).hexdigest()

        cache = _helpers.get_cache("wsfactory")
        cache.set(cls.CACHE_KEY, config._hash)
        config._configured = True

        logger.debug(
            "Configuration file %s successfully loaded" % config_path)
Пример #3
0
    def inner(*args, **kwargs):
        if not Settings.configured():
            config_path = getattr(settings, "WSFACTORY_CONFIG_FILE")
            logger.info("Not configured yet. Load configuration %s" %
                        config_path)
            Settings.load(config_path)
        cache = _helpers.get_cache("wsfactory")
        if Settings.hash() != cache.get(Settings.CACHE_KEY):
            logger.info("Configuration file was changed. Reloading ...")
            Settings.reload()

        return fn(*args, **kwargs)
Пример #4
0
    def inner(*args, **kwargs):
        if not Settings.configured():
            config_path = getattr(settings, "WSFACTORY_CONFIG_FILE")
            logger.info(
                "Not configured yet. Load configuration %s" % config_path)
            Settings.load(config_path)
        cache = _helpers.get_cache("wsfactory")
        if Settings.hash() != cache.get(Settings.CACHE_KEY):
            logger.info("Configuration file was changed. Reloading ...")
            Settings.reload()

        return fn(*args, **kwargs)