# HG changeset patch # User RhodeCode Admin # Date 2024-02-27 08:50:56 # Node ID 688c59491876b690200b806bf88551c3b5979d3f # Parent cf4b8591e59ad99f04f51dac6da58a8ac636130f fix(api.url): set default api.url and re-use defaults in ssh wrappers diff --git a/rhodecode/api/__init__.py b/rhodecode/api/__init__.py --- a/rhodecode/api/__init__.py +++ b/rhodecode/api/__init__.py @@ -22,7 +22,6 @@ import sys import fnmatch import decorator -import typing import venusian from collections import OrderedDict @@ -45,7 +44,7 @@ from rhodecode.model.db import User, Use log = logging.getLogger(__name__) DEFAULT_RENDERER = 'jsonrpc_renderer' -DEFAULT_URL = '/_admin/apiv2' +DEFAULT_URL = '/_admin/api' SERVICE_API_IDENTIFIER = 'service_' diff --git a/rhodecode/config/middleware.py b/rhodecode/config/middleware.py --- a/rhodecode/config/middleware.py +++ b/rhodecode/config/middleware.py @@ -26,13 +26,13 @@ import logging.config from paste.gzipper import make_gzip_middleware import pyramid.events from pyramid.wsgi import wsgiapp -from pyramid.authorization import ACLAuthorizationPolicy from pyramid.config import Configurator from pyramid.settings import asbool, aslist from pyramid.httpexceptions import ( HTTPException, HTTPError, HTTPInternalServerError, HTTPFound, HTTPNotFound) from pyramid.renderers import render_to_response +from rhodecode import api from rhodecode.model import meta from rhodecode.config import patches from rhodecode.config import utils as config_utils @@ -527,7 +527,7 @@ def sanitize_settings_and_apply_defaults # TODO: johbo: Re-think this, usually the call to config.include # should allow to pass in a prefix. - settings_maker.make_setting('rhodecode.api.url', '/_admin/api') + settings_maker.make_setting('rhodecode.api.url', api.DEFAULT_URL) # Sanitize generic settings. settings_maker.make_setting('default_encoding', 'UTF-8', parser='list') diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py --- a/rhodecode/lib/utils.py +++ b/rhodecode/lib/utils.py @@ -837,7 +837,13 @@ def call_service_api(ini_path, payload): "Please ensure that app.service_api.host and app.service_api.token are " "defined inside of .ini configuration file." ) - api_url = config.get('app:main', 'rhodecode.api.url') + try: + api_url = config.get('app:main', 'rhodecode.api.url') + except NoOptionError: + from rhodecode import api + log.debug('Cannot find rhodecode.api.url, setting API URL TO Default value') + api_url = api.DEFAULT_URL + payload.update({ 'id': 'service', 'auth_token': config.get('app:main', 'app.service_api.token')