# HG changeset patch # User Mads Kiilerich # Date 2020-01-03 01:55:06 # Node ID 7fdefd3c5bd59d0588762f10a83399a6b4e673c6 # Parent 9584eb51ae527aff11c0cb6bf1b320bacf3280b0 cache: drop setup_cache_regions - tg will already have done that and coerced the types correctly The configuration and type fixing will be invoked from make_base_app, and we will thus not have to do it: File "kallithea/config/middleware.py", line 31, in make_app_without_logging return make_base_app(global_conf, full_stack=full_stack, **app_conf) File ".../python3.7/site-packages/tg/configuration/app_config.py", line 176, in make_base_app wrap_app) File ".../python3.7/site-packages/tg/configurator/application.py", line 112, in _make_app app = TGApp(conf) File ".../python3.7/site-packages/tg/wsgiapp.py", line 49, in __init__ app_wrapper = wrapper(self.wrapped_dispatch, self.config) File ".../python3.7/site-packages/tg/appwrappers/caching.py", line 36, in __init__ self.options = parse_cache_config_options(config) File ".../python3.7/site-packages/beaker/util.py", line 430, in parse_cache_config_options This will fix a py3 problem where setup_cache_regions was run *after* beaker had coerced types, thus introducing string types in the config where beaker expected the integers it had put there. diff --git a/kallithea/bin/kallithea_cli_base.py b/kallithea/bin/kallithea_cli_base.py --- a/kallithea/bin/kallithea_cli_base.py +++ b/kallithea/bin/kallithea_cli_base.py @@ -75,7 +75,6 @@ def register_command(config_file=False, logging.config.fileConfig(io.StringIO(config_string)) if config_file_initialize_app: kallithea.config.middleware.make_app_without_logging(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) - kallithea.lib.utils.setup_cache_regions(kallithea.CONFIG) return annotated(*args, **kwargs) return cli_command(runtime_wrapper) return annotator diff --git a/kallithea/lib/hooks.py b/kallithea/lib/hooks.py --- a/kallithea/lib/hooks.py +++ b/kallithea/lib/hooks.py @@ -303,7 +303,6 @@ def _hook_environment(repo_path): """ import paste.deploy import kallithea.config.middleware - import kallithea.lib.utils extras = get_hook_environment() @@ -311,7 +310,6 @@ def _hook_environment(repo_path): kallithea.CONFIG = paste.deploy.appconfig('config:' + path_to_ini_file) #logging.config.fileConfig(ini_file_path) # Note: we are in a different process - don't use configured logging kallithea.config.middleware.make_app_without_logging(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) - kallithea.lib.utils.setup_cache_regions(kallithea.CONFIG) repo_path = safe_unicode(repo_path) # fix if it's not a bare repo diff --git a/kallithea/lib/utils.py b/kallithea/lib/utils.py --- a/kallithea/lib/utils.py +++ b/kallithea/lib/utils.py @@ -33,10 +33,9 @@ import sys import traceback from distutils.version import StrictVersion -import beaker +import beaker.cache import mercurial.config import mercurial.ui -from beaker.cache import _cache_decorate from tg.i18n import ugettext as _ import kallithea.config.conf @@ -622,36 +621,6 @@ def check_git_version(): # CACHE RELATED METHODS #=============================================================================== -# set cache regions for beaker so celery can utilise it -def setup_cache_regions(settings): - # Create dict with just beaker cache configs with prefix stripped - cache_settings = {'regions': None} - prefix = 'beaker.cache.' - for key in settings: - if key.startswith(prefix): - name = key[len(prefix):] - cache_settings[name] = settings[key] - # Find all regions, apply defaults, and apply to beaker - if cache_settings['regions']: - for region in cache_settings['regions'].split(','): - region = region.strip() - prefix = region + '.' - region_settings = {} - for key in cache_settings: - if key.startswith(prefix): - name = key[len(prefix):] - region_settings[name] = cache_settings[key] - region_settings.setdefault('expire', - cache_settings.get('expire', '60')) - region_settings.setdefault('lock_dir', - cache_settings.get('lock_dir')) - region_settings.setdefault('data_dir', - cache_settings.get('data_dir')) - region_settings.setdefault('type', - cache_settings.get('type', 'memory')) - beaker.cache.cache_regions[region] = region_settings - - def conditional_cache(region, prefix, condition, func): """ @@ -674,6 +643,6 @@ def conditional_cache(region, prefix, co if condition: log.debug('conditional_cache: True, wrapping call of ' 'func: %s into %s region cache' % (region, func)) - wrapped = _cache_decorate((prefix,), None, None, region)(func) + wrapped = beaker.cache._cache_decorate((prefix,), None, None, region)(func) return wrapped diff --git a/kallithea/tests/scripts/manual_test_concurrency.py b/kallithea/tests/scripts/manual_test_concurrency.py --- a/kallithea/tests/scripts/manual_test_concurrency.py +++ b/kallithea/tests/scripts/manual_test_concurrency.py @@ -41,7 +41,6 @@ from sqlalchemy import engine_from_confi from kallithea.config.environment import load_environment from kallithea.lib.auth import get_crypt_password -from kallithea.lib.utils import setup_cache_regions from kallithea.model import meta from kallithea.model.base import init_model from kallithea.model.db import Repository, Ui, User @@ -52,8 +51,6 @@ rel_path = dirname(dirname(dirname(dirna conf = appconfig('config:development.ini', relative_to=rel_path) load_environment(conf.global_conf, conf.local_conf) -setup_cache_regions(conf) - USER = TEST_USER_ADMIN_LOGIN PASS = TEST_USER_ADMIN_PASS HOST = 'server.local'