##// END OF EJS Templates
fix(bootstrap): fixed issues that lead to leaving rhodecode.local as a default setting which is now explicitly read from .ini config
super-admin -
r5430:2f6a1e33 default
parent child Browse files
Show More
@@ -19,6 +19,8 b''
19 19 import os
20 20 import platform
21 21
22 DEFAULT_USER = 'default'
23
22 24
23 25 def configure_vcs(config):
24 26 """
@@ -92,13 +94,14 b' def set_instance_id(config):'
92 94
93 95
94 96 def get_default_user_id():
95 DEFAULT_USER = 'default'
96 97 from sqlalchemy import text
97 98 from rhodecode.model import meta
98 99
99 100 engine = meta.get_engine()
100 101 with meta.SA_Session(engine) as session:
101 result = session.execute(text("SELECT user_id from users where username = :uname"), {'uname': DEFAULT_USER})
102 result = session.execute(text(
103 "SELECT user_id from users where username = :uname"
104 ), {'uname': DEFAULT_USER})
102 105 user_id = result.first()[0]
103 106
104 107 return user_id
@@ -19,30 +19,26 b''
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 import os
22 import configparser
23 22
24 from rhodecode.lib.config_utils import get_config
25 23 from pyramid.paster import bootstrap as pyramid_bootstrap, setup_logging # pragma: no cover
26 24 from pyramid.threadlocal import get_current_request as pyramid_current_request
27 25
28 26
29 27 def bootstrap(config_uri, options=None, env=None):
28 from rhodecode.config.utils import DEFAULT_USER
29 from rhodecode.lib.config_utils import get_app_config_lightweight
30 30 from rhodecode.lib.utils2 import AttributeDict
31 31 from rhodecode.lib.request import Request
32 32
33 33 if env:
34 34 os.environ.update(env)
35 35
36 config = get_config(config_uri)
37 base_url = 'http://rhodecode.local'
38 try:
39 base_url = config.get('app:main', 'app.base_url')
40 except (configparser.NoSectionError, configparser.NoOptionError):
41 pass
36 config = get_app_config_lightweight(config_uri)
37 base_url = config['app.base_url']
42 38
43 39 request = Request.blank('/', base_url=base_url)
44 40 # fake inject a running user for bootstrap request !
45 request.user = AttributeDict({'username': 'bootstrap-user',
41 request.user = AttributeDict({'username': DEFAULT_USER,
46 42 'user_id': 1,
47 43 'ip_addr': '127.0.0.1'})
48 44 return pyramid_bootstrap(config_uri, request=request, options=options)
General Comments 0
You need to be logged in to leave comments. Login now