##// 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 import os
19 import os
20 import platform
20 import platform
21
21
22 DEFAULT_USER = 'default'
23
22
24
23 def configure_vcs(config):
25 def configure_vcs(config):
24 """
26 """
@@ -92,13 +94,14 b' def set_instance_id(config):'
92
94
93
95
94 def get_default_user_id():
96 def get_default_user_id():
95 DEFAULT_USER = 'default'
96 from sqlalchemy import text
97 from sqlalchemy import text
97 from rhodecode.model import meta
98 from rhodecode.model import meta
98
99
99 engine = meta.get_engine()
100 engine = meta.get_engine()
100 with meta.SA_Session(engine) as session:
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 user_id = result.first()[0]
105 user_id = result.first()[0]
103
106
104 return user_id
107 return user_id
@@ -19,30 +19,26 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import os
21 import os
22 import configparser
23
22
24 from rhodecode.lib.config_utils import get_config
25 from pyramid.paster import bootstrap as pyramid_bootstrap, setup_logging # pragma: no cover
23 from pyramid.paster import bootstrap as pyramid_bootstrap, setup_logging # pragma: no cover
26 from pyramid.threadlocal import get_current_request as pyramid_current_request
24 from pyramid.threadlocal import get_current_request as pyramid_current_request
27
25
28
26
29 def bootstrap(config_uri, options=None, env=None):
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 from rhodecode.lib.utils2 import AttributeDict
30 from rhodecode.lib.utils2 import AttributeDict
31 from rhodecode.lib.request import Request
31 from rhodecode.lib.request import Request
32
32
33 if env:
33 if env:
34 os.environ.update(env)
34 os.environ.update(env)
35
35
36 config = get_config(config_uri)
36 config = get_app_config_lightweight(config_uri)
37 base_url = 'http://rhodecode.local'
37 base_url = config['app.base_url']
38 try:
39 base_url = config.get('app:main', 'app.base_url')
40 except (configparser.NoSectionError, configparser.NoOptionError):
41 pass
42
38
43 request = Request.blank('/', base_url=base_url)
39 request = Request.blank('/', base_url=base_url)
44 # fake inject a running user for bootstrap request !
40 # fake inject a running user for bootstrap request !
45 request.user = AttributeDict({'username': 'bootstrap-user',
41 request.user = AttributeDict({'username': DEFAULT_USER,
46 'user_id': 1,
42 'user_id': 1,
47 'ip_addr': '127.0.0.1'})
43 'ip_addr': '127.0.0.1'})
48 return pyramid_bootstrap(config_uri, request=request, options=options)
44 return pyramid_bootstrap(config_uri, request=request, options=options)
General Comments 0
You need to be logged in to leave comments. Login now