diff --git a/jupyterlab_server/handlers.py b/jupyterlab_server/handlers.py index aeff694..79df953 100644 --- a/jupyterlab_server/handlers.py +++ b/jupyterlab_server/handlers.py @@ -20,6 +20,7 @@ from .licenses_handler import LicensesHandler, LicensesManager from .listings_handler import ListingsHandler, fetch_listings from .settings_handler import SettingsHandler +from .settings_utils import _get_overrides from .themes_handler import ThemesHandler from .translations_handler import TranslationsHandler from .workspaces_handler import WorkspacesHandler, WorkspacesManager @@ -227,11 +228,19 @@ def add_handlers(handlers: list[Any], extension_app: LabServerApp) -> None: # Handle local settings. if extension_app.schemas_dir: + # Load overrides once, rather than in each copy of the settings handler + overrides, error = _get_overrides(extension_app.app_settings_dir) + + if error: + overrides_warning = "Failed loading overrides: %s" + extension_app.log.warning(overrides_warning, error) + settings_config: dict[str, Any] = { "app_settings_dir": extension_app.app_settings_dir, "schemas_dir": extension_app.schemas_dir, "settings_dir": extension_app.user_settings_dir, "labextensions_path": labextensions_path, + "overrides": overrides, } # Handle requests for the list of settings. Make slash optional. diff --git a/jupyterlab_server/settings_handler.py b/jupyterlab_server/settings_handler.py index 4e2794a..005cf0c 100644 --- a/jupyterlab_server/settings_handler.py +++ b/jupyterlab_server/settings_handler.py @@ -25,11 +25,12 @@ def initialize( # type:ignore[override] schemas_dir: str, settings_dir: str, labextensions_path: list[str], + overrides: dict[str, Any], **kwargs: Any, # noqa: ARG002 ) -> None: """Initialize the handler.""" SchemaHandler.initialize( - self, app_settings_dir, schemas_dir, settings_dir, labextensions_path + self, app_settings_dir, schemas_dir, settings_dir, labextensions_path, overrides ) ExtensionHandlerMixin.initialize(self, name) diff --git a/jupyterlab_server/settings_utils.py b/jupyterlab_server/settings_utils.py index 5904b6c..101dc33 100644 --- a/jupyterlab_server/settings_utils.py +++ b/jupyterlab_server/settings_utils.py @@ -448,20 +448,17 @@ def initialize( schemas_dir: str, settings_dir: str, labextensions_path: list[str] | None, + overrides: dict[str, Any], **kwargs: Any, ) -> None: """Initialize the handler.""" super().initialize(**kwargs) - self.overrides, error = _get_overrides(app_settings_dir) + self.overrides = overrides self.app_settings_dir = app_settings_dir self.schemas_dir = schemas_dir self.settings_dir = settings_dir self.labextensions_path = labextensions_path - if error: - overrides_warning = "Failed loading overrides: %s" - self.log.warning(overrides_warning, error) - def get_current_locale(self) -> str: """ Get the current locale as specified in the translation-extension settings.