flask_more_smorest.perms.models.setting

UserSetting model for key-value storage.

Classes

UserSetting(**kwargs)

User-specific key-value settings storage.

class flask_more_smorest.perms.models.setting.UserSetting(**kwargs)[source]

User-specific key-value settings storage.

This is a concrete implementation of AbstractUserSetting. For customization, subclass AbstractUserSetting instead of this class.

Permission checks are delegated to the owning user (inherited from AbstractUserSetting).

Example

from sqlalchemy.orm import Mapped, mapped_column

class CustomSetting(AbstractUserSetting):

__tablename__ = “user_setting” metadata: Mapped[dict] = mapped_column(sa.JSON) __table_args__ = (db.UniqueConstraint(“user_id”, “key”),)

__init__(**kwargs)

Initialize model after checking sub-fields can be created.

created_at
id
key: Mapped[str]
updated_at
user

Relationship to the registered User model.

Uses lazy resolution via lambda to support custom User models registered through init_fms(). The lambda is evaluated during mapper configuration, allowing get_user_model() to return the correct registered User class.

user_id
value: Mapped[str | None]