changeset 7806:87672c1916f8

config: stop using the app_conf sub key - TurboGears2 2.4 will drop it All [app:main] settings *except* cache_dir are also available at the top level. cache_dir can be found as tg.cache_dir .
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 22 Jul 2019 04:38:22 +0200
parents b077cf7e7f90
children 2d2fcf8f4221
files kallithea/config/app_cfg.py kallithea/controllers/search.py kallithea/lib/celerylib/__init__.py kallithea/lib/celerylib/tasks.py kallithea/tests/functional/test_search.py
diffstat 5 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/config/app_cfg.py	Mon Jul 22 04:18:37 2019 +0200
+++ b/kallithea/config/app_cfg.py	Mon Jul 22 04:38:22 2019 +0200
@@ -156,8 +156,8 @@
             sys.exit(1)
 
     # store some globals into kallithea
-    kallithea.CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
-    kallithea.CELERY_EAGER = str2bool(config['app_conf'].get('celery.always.eager'))
+    kallithea.CELERY_ON = str2bool(config.get('use_celery'))
+    kallithea.CELERY_EAGER = str2bool(config.get('celery.always.eager'))
     kallithea.CONFIG = config
 
     load_rcextensions(root_path=config['here'])
--- a/kallithea/controllers/search.py	Mon Jul 22 04:18:37 2019 +0200
+++ b/kallithea/controllers/search.py	Mon Jul 22 04:38:22 2019 +0200
@@ -84,7 +84,7 @@
         if c.cur_query:
             p = safe_int(request.GET.get('page'), 1)
             highlight_items = set()
-            index_dir = config['app_conf']['index_dir']
+            index_dir = config['index_dir']
             try:
                 if not exists_in(index_dir, index_name):
                     raise EmptyIndexError
--- a/kallithea/lib/celerylib/__init__.py	Mon Jul 22 04:18:37 2019 +0200
+++ b/kallithea/lib/celerylib/__init__.py	Mon Jul 22 04:38:22 2019 +0200
@@ -104,7 +104,7 @@
 def locked_task(func):
     def __wrapper(func, *fargs, **fkwargs):
         lockkey = __get_lockkey(func, *fargs, **fkwargs)
-        lockkey_path = config['app_conf']['cache_dir']
+        lockkey_path = config['tg.cache_dir']  # The configured cache_dir is only available under this name ...
 
         log.info('running task with lockkey %s', lockkey)
         try:
--- a/kallithea/lib/celerylib/tasks.py	Mon Jul 22 04:18:37 2019 +0200
+++ b/kallithea/lib/celerylib/tasks.py	Mon Jul 22 04:38:22 2019 +0200
@@ -75,7 +75,7 @@
     DBS = celerylib.get_session()
     lockkey = celerylib.__get_lockkey('get_commits_stats', repo_name, ts_min_y,
                             ts_max_y)
-    lockkey_path = config['app_conf']['cache_dir']
+    lockkey_path = config['tg.cache_dir']  # The configured cache_dir is only available under this name ...
 
     log.info('running task with lockkey %s', lockkey)
 
@@ -99,7 +99,7 @@
             return True
 
         skip_date_limit = True
-        parse_limit = int(config['app_conf'].get('commit_parse_limit'))
+        parse_limit = int(config.get('commit_parse_limit'))
         last_rev = None
         last_cs = None
         timegetter = itemgetter('time')
--- a/kallithea/tests/functional/test_search.py	Mon Jul 22 04:18:37 2019 +0200
+++ b/kallithea/tests/functional/test_search.py	Mon Jul 22 04:38:22 2019 +0200
@@ -16,10 +16,8 @@
         self.log_user()
 
         config_mock = {
-            'app_conf': {
-                # can be any existing dir that does not contain an actual index
-                'index_dir': str(tmpdir),
-            }
+            # can be any existing dir that does not contain an actual index
+            'index_dir': str(tmpdir),
         }
         with mock.patch('kallithea.controllers.search.config', config_mock):
             response = self.app.get(url(controller='search', action='index'),