fix(bootstrap): fixed issues that lead to leaving rhodecode.local as a default setting which is now explicitly read from .ini config
This commit is contained in:
parent
b549afbfee
commit
80f7b38d7d
2 changed files with 10 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue