##// END OF EJS Templates
fix(backend): fixed broken backends function after python3 migration
super-admin -
r5523:112c3403 stable
parent child Browse files
Show More
@@ -1,87 +1,87 b''
1 1 # Copyright (C) 2010-2023 RhodeCode GmbH
2 2 #
3 3 # This program is free software: you can redistribute it and/or modify
4 4 # it under the terms of the GNU Affero General Public License, version 3
5 5 # (only), as published by the Free Software Foundation.
6 6 #
7 7 # This program is distributed in the hope that it will be useful,
8 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 10 # GNU General Public License for more details.
11 11 #
12 12 # You should have received a copy of the GNU Affero General Public License
13 13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 14 #
15 15 # This program is dual-licensed. If you wish to learn more about the
16 16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18 18
19 19 import os
20 20 import logging
21 21 import rhodecode
22 22 import collections
23 23
24 24 from rhodecode.config import utils
25 25
26 26 from rhodecode.lib.utils import load_rcextensions
27 27 from rhodecode.lib.utils2 import str2bool
28 28 from rhodecode.lib.vcs import connect_vcs
29 29
30 30 log = logging.getLogger(__name__)
31 31
32 32
33 33 def load_pyramid_environment(global_config, settings):
34 34 # Some parts of the code expect a merge of global and app settings.
35 35 settings_merged = global_config.copy()
36 36 settings_merged.update(settings)
37 37
38 38 # TODO(marcink): probably not required anymore
39 39 # configure channelstream,
40 40 settings_merged['channelstream_config'] = {
41 41 'enabled': str2bool(settings_merged.get('channelstream.enabled', False)),
42 42 'server': settings_merged.get('channelstream.server'),
43 43 'secret': settings_merged.get('channelstream.secret')
44 44 }
45 45
46 46 # If this is a test run we prepare the test environment like
47 47 # creating a test database, test search index and test repositories.
48 48 # This has to be done before the database connection is initialized.
49 49 if rhodecode.is_test:
50 50 rhodecode.disable_error_handler = True
51 51 from rhodecode import authentication
52 52 authentication.plugin_default_auth_ttl = 0
53 53
54 54 utils.initialize_test_environment(settings_merged)
55 55
56 56 # Initialize the database connection.
57 57 utils.initialize_database(settings_merged)
58 58
59 59 load_rcextensions(root_path=settings_merged['here'])
60 60
61 61 # Limit backends to `vcs.backends` from configuration, and preserve the order
62 for alias in rhodecode.BACKENDS.keys():
62 for alias in list(rhodecode.BACKENDS.keys()):
63 63 if alias not in settings['vcs.backends']:
64 64 del rhodecode.BACKENDS[alias]
65 65
66 66 _sorted_backend = sorted(rhodecode.BACKENDS.items(),
67 67 key=lambda item: settings['vcs.backends'].index(item[0]))
68 68 rhodecode.BACKENDS = collections.OrderedDict(_sorted_backend)
69 69
70 log.info('Enabled VCS backends: %s', rhodecode.BACKENDS.keys())
70 log.info('Enabled VCS backends: %s', list(rhodecode.BACKENDS.keys()))
71 71
72 72 # initialize vcs client and optionally run the server if enabled
73 73 vcs_server_uri = settings['vcs.server']
74 74 vcs_server_enabled = settings['vcs.server.enable']
75 75
76 76 utils.configure_vcs(settings)
77 77
78 78 # Store the settings to make them available to other modules.
79 79
80 80 rhodecode.PYRAMID_SETTINGS = settings_merged
81 81 rhodecode.CONFIG = settings_merged
82 82 rhodecode.CONFIG['default_user_id'] = utils.get_default_user_id()
83 83
84 84 if vcs_server_enabled:
85 85 connect_vcs(vcs_server_uri, utils.get_vcs_server_protocol(settings))
86 86 else:
87 87 log.warning('vcs-server not enabled, vcs connection unavailable')
General Comments 0
You need to be logged in to leave comments. Login now