# HG changeset patch # User RhodeCode Admin # Date 2024-06-13 08:43:17 # Node ID 2f6a1e33c4b22e75d58e9dcc8ee188f7f55b439b # Parent e153339b8fb6e8eb09ca801751d5375b78d69831 fix(bootstrap): fixed issues that lead to leaving rhodecode.local as a default setting which is now explicitly read from .ini config diff --git a/rhodecode/config/utils.py b/rhodecode/config/utils.py --- a/rhodecode/config/utils.py +++ b/rhodecode/config/utils.py @@ -19,6 +19,8 @@ import os import platform +DEFAULT_USER = 'default' + def configure_vcs(config): """ @@ -92,13 +94,14 @@ def set_instance_id(config): def get_default_user_id(): - DEFAULT_USER = 'default' from sqlalchemy import text from rhodecode.model import meta engine = meta.get_engine() with meta.SA_Session(engine) as session: - result = session.execute(text("SELECT user_id from users where username = :uname"), {'uname': DEFAULT_USER}) + result = session.execute(text( + "SELECT user_id from users where username = :uname" + ), {'uname': DEFAULT_USER}) user_id = result.first()[0] return user_id diff --git a/rhodecode/lib/pyramid_utils.py b/rhodecode/lib/pyramid_utils.py --- a/rhodecode/lib/pyramid_utils.py +++ b/rhodecode/lib/pyramid_utils.py @@ -19,30 +19,26 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import os -import configparser -from rhodecode.lib.config_utils import get_config from pyramid.paster import bootstrap as pyramid_bootstrap, setup_logging # pragma: no cover from pyramid.threadlocal import get_current_request as pyramid_current_request def bootstrap(config_uri, options=None, env=None): + from rhodecode.config.utils import DEFAULT_USER + from rhodecode.lib.config_utils import get_app_config_lightweight from rhodecode.lib.utils2 import AttributeDict from rhodecode.lib.request import Request if env: os.environ.update(env) - config = get_config(config_uri) - base_url = 'http://rhodecode.local' - try: - base_url = config.get('app:main', 'app.base_url') - except (configparser.NoSectionError, configparser.NoOptionError): - pass + config = get_app_config_lightweight(config_uri) + base_url = config['app.base_url'] request = Request.blank('/', base_url=base_url) # fake inject a running user for bootstrap request ! - request.user = AttributeDict({'username': 'bootstrap-user', + request.user = AttributeDict({'username': DEFAULT_USER, 'user_id': 1, 'ip_addr': '127.0.0.1'}) return pyramid_bootstrap(config_uri, request=request, options=options)