Extension Runtime configuration editing via API


Extension Basics

Title
Runtime configuration editing via API
Name
ckanext-editable-config
Type
Public extension
Description
Edit CKAN configuration options at runtime without server restart
CKAN versions

~2.9, ~2.10, ~2.11

Show details
Download-Url (zip)
Download-Url commit date
2024-04-24
Url to repo
Category
Specialized Tools


Background Infos

Description (long)
Show details

This plugin provides a comprehensive API for overriding CKAN configuration options and applying changes to the application without restarting the web server. Features include: API actions for changing, reverting, and resetting config options in runtime, safe modification of options marked with ‘editable: true’ flag, validation of all changes using declared validators before applying, three types of modifications (change to new value, revert to previous value, reset to config file value), whitelist/blacklist control for editable options via configuration, additional custom validators for enhanced safety, configurable change detection cycle with timeout, optional conversion of existing core AdminUI overrides to editable config format, ability to disable or replace CKAN’s built-in AdminUI Config tab with custom form, environment variable for emergency disabling (CKANEXT_EDITABLE_CONFIG_DISABLE), API actions include editable_config_update (combined action), editable_config_change, editable_config_revert, editable_config_reset, editable_config_list, editable_config_last_check. Requires CKAN 2.10+. All API actions require sysadmin access. Compatible with runtime modification of most config options except those used during WSGI app initialization (beaker settings, debug flag, some plugin hooks).

Version
0.0.6
Version release date
2024-04-24
Contact name
DataShades
Contakt email
(not set)
Contact Url
(not set)


Installation Guide

Configuration hints

Install and enable the plugin:

pip install ckanext-editable-config

ckan.plugins = editable_config

Optional configuration settings:

Additional options to make editable (use with caution)

ckanext.editable_config.options.extra_editable = ckan.datasets_per_page ckan.auth.user_create_groups

Whitelist - only these editable options can be changed

ckanext.editable_config.options.whitelist = ckan.site_title ckan.site_description

Blacklist - disable editable flag for specified options

ckanext.editable_config.options.blacklist = ckan.site_title ckan.site_description

Minimal seconds between change detection cycles (default: 0)

ckanext.editable_config.charge_timeout = 10

Additional validators for config options (JSON dict)

ckanext.editable_config.additional_validators = {“ckan.site_title”: “less_than_100 do_not_contain_exclamation_mark”}

Remove Config tab from CKAN Admin UI (default: false)

ckanext.editable_config.disable_admin_config_tab = True

Replace Config tab with basic form for editable options (default: false)

ckanext.editable_config.replace_admin_config_tab = True

Auto-convert existing core AdminUI overrides (default: false)

ckanext.editable_config.convert_core_overrides = True

API usage examples:

Change via Python: tk.get_action(“editable_config_update”)( {“ignore_auth”: True}, {“change”: {“ckan.site_title”: “Updated title”}} )

Change via CLI: ckanapi action editable_config_update change:’{“ckan.site_title”: “Updated”}’

Change via JavaScript: await fetch(“/api/action/editable_config_update”, { method: “POST”, body: JSON.stringify({change: {“ckan.site_title”: “Updated”}}), headers: {“content-type”: “application/json”} })

Emergency disable: CKANEXT_EDITABLE_CONFIG_DISABLE=1 ckanapi action editable_config_revert keys=BAD_OPTION

Limitations: Cannot change debug, beaker, middlewares, blueprints, CLI commands, or translations in runtime. Not compatible with CKAN’s built-in AdminUI Config form - use convert_core_overrides or avoid mixing both approaches.

Plugins to configure (ckan.ini)
editable_config
CKAN Settings (ckan.ini)
# ckanext.editable_config.options.extra_editable = ckan.datasets_per_page ckan.auth.user_create_groups # ckanext.editable_config.options.whitelist = ckan.site_title ckan.site_description # ckanext.editable_config.options.blacklist = ckan.site_title ckan.site_description # ckanext.editable_config.charge_timeout = 10 # ckanext.editable_config.additional_validators = {"ckan.site_title": "less_than_100 do_not_contain_exclamation_mark"} # ckanext.editable_config.disable_admin_config_tab = True # ckanext.editable_config.replace_admin_config_tab = True # ckanext.editable_config.convert_core_overrides = True # CKANEXT_EDITABLE_CONFIG_DISABLE = 1 ckanapi action editable_config_revert keys=BAD_OPTION_NAME
DB migration to be executed
editable_config
<< back to Extensions