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