Scoped Settings¶
MedUX uses Conjunto's scoped settings system for runtime configuration that can vary by scope.
Priority Chain¶
Settings cascade through five priority levels, from highest to lowest:
USER > DEVICE > GROUP > TENANT > VENDOR
A user-level setting overrides the same key set at the tenant level. A tenant-level setting overrides the vendor default.
Registering Settings¶
Every (namespace, key) pair must be registered at startup in a
scoped_settings.py module within an installed app. Conjunto
auto-discovers these modules.
# myapp/scoped_settings.py
from conjunto.settings.scoped import ScopedSettingsRegistry
registry = ScopedSettingsRegistry()
registry.register(
namespace="myapp",
key="items_per_page",
default=25,
label="Items per page",
help_text="Number of items shown per page in list views.",
)
See src/medux/common/scoped_settings.py for a real example.
Reading Settings¶
In Views¶
value = request.scoped_settings.get("myapp", "items_per_page")
# or with a fallback default:
value = request.scoped_settings.get("myapp", "items_per_page", default=25)
In Templates¶
{{ request.scoped_settings.myapp.items_per_page }}
Settings Locking¶
Higher scopes can lock settings, preventing lower scopes from overriding them. For example, a tenant admin can lock a setting so that individual users cannot change it.
Settings UI¶
Plugins contribute settings sections to the /settings/ page by
implementing ISettingsSection (from conjunto.api.interfaces). Each
section renders a form with the plugin's configurable settings.
Note
The legacy medux.preferences app and its preferences.toml seed
file have been removed. All configuration goes through scoped
settings now.