API¶
Here you can find part of documentation that covers all public interfaces of Flask-Constance.
Extension object¶
- class flask_constance.Constance(app=None, backend=None, cache=None, view_base_url=None, view_class=<class 'flask_constance.view.ConstanceView'>)[source]¶
Bases:
object
Constance extension
- Parameters:
app (
Optional
[Flask
]) – Flask application.backend (
Optional
[Backend
]) – Backend instance to use.backend_cache – Cache for the backend.
view_base_url (
Optional
[str
]) – Base URL to register REST-like view for settings.view_class (
Type
[ConstanceView
]) – Class to register as view.
Global settings object¶
Storage aka settings object¶
- class flask_constance.storage.Storage(backend, cache=None)[source]¶
Bases:
object
Flask-Constance settings storage.
This is access point for getting and setting constance settings.
- Parameters:
backend (
Backend
) – Backend instance to use. By default is Memory backend.cache (
Optional
[BackendCache
]) – Caching backend to use. This is optional.
Backends¶
Flask-Constance supports various types of backends.
All of them implements Backend
or flask_constance.backends.base.BackendCache
protocols.
Backend Protocol¶
Backend Cache Protocol¶
Memory Backend object¶
Memory backend was implemented for testing purposes. It can be used only in single-process mode, so it really doesn’t fit production environment requirenments.
Flask-SQLAlchemy backend object¶
This backend implements intergration with Flask-SQLAlchemy extension as main settings storage.
Flask-SQLAlchemy model mixin¶
Mixin that will define all needed sqlalchemy fiels for your model.
- class flask_constance.backends.fsqla.SettingMixin[source]¶
Bases:
object
Model mixin for Flask-SQLAlchemy backend
- id = Column(None, Integer(), table=None, primary_key=True, nullable=False)¶
- name = Column(None, String(length=256), table=None, nullable=False)¶
- value = Column(None, JSON(), table=None)¶
Signals¶
- flask_constance.signals.constance_setup¶
Signal that called after extension was initialized. Called with 2 agruments:
Instance of
Constance
.Instance of Flask application.
- flask_constance.signals.constance_get¶
Signal that called after setting value was accessed. Called with 2 arguments:
Instance of
Constance
.Name of the setting that was accessed.
- flask_constance.signals.constance_set¶
Signal that called after setting value was updated. Called with 3 arguments:
Instance of
Constance
.Name of the setting that was updated.
New value of the setting.
RESTlike view¶
View implementing RESTlike interface for managing Flask-Constance dynamic settings.
- class flask_constance.view.ConstanceView[source]¶
Bases:
MethodView
Method view for managing dynamic settings.
-
methods:
ClassVar
[Optional
[Collection
[str
]]] = {'DELETE', 'GET', 'PUT'}¶ The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
-
methods: