%global _empty_manifest_terminate_build 0 Name: python-dj-dynamic-settings Version: 0.2.3 Release: 1 Summary: Stay informed of it License: MIT URL: https://bitbucket.org/akinonteam/dj-dynamic-settings/ Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ce/9c/7e27f8f226215b95996ab3819367a77637bb86f0fcd55a8241dcba5109f3/dj-dynamic-settings-0.2.3.tar.gz BuildArch: noarch %description # Django Dynamic Settings [![Build status](https://img.shields.io/bitbucket/pipelines/akinonteam/dj-dynamic-settings)](https://bitbucket.org/akinonteam/dj-dynamic-settings/addon/pipelines/home) ![PyPI](https://img.shields.io/pypi/v/dj-dynamic-settings) ![PyPI - Django version](https://img.shields.io/pypi/djversions/dj-dynamic-settings) ![PyPI - Python version](https://img.shields.io/pypi/pyversions/dj-dynamic-settings) ![PyPI - License](https://img.shields.io/pypi/l/dj-dynamic-settings) Django Dynamic Settings allows you to create & use dynamic settings backed by a database. ## Installation Installation using pip: ``` pip install dj-dynamic-settings ``` `dj_dynamic_settings` app has to be added to `INSTALLED_APPS` and `migrate` command has to be run. ```python INSTALLED_APPS = ( # other apps here... "dj_dynamic_settings", ) ``` `dj_dynamic_settings.urls` must be included to a desired url path. ```python urlpatterns = [ ..., url(r"^api/v1/", include("dj_dynamic_settings.urls")), ] ``` Setting class must be defined & registered. Please make sure that this class' module runs whenever the application runs. ```python from dj_dynamic_settings.registry import BaseSetting, registry from dj_dynamic_settings.validators import TypeValidator @registry.register class FeatureActive(BaseSetting): key = "FEATURE_ACTIVE" validators = [TypeValidator(bool)] default = False description = "Flag for Feature X" ``` Create `Setting` instance using view. ```python import requests requests.post( url="https://your-app.com/api/v1/dynamic_settings/", headers={ "Authorization": "Token ", }, json={ "key": "FEATURE_ACTIVE", "value": True, "is_active": True, } ) ``` Access this setting as in `django.conf.settings` ```python from dj_dynamic_settings.conf import settings settings.FEATURE_ACTIVE # True ``` ### Create / Update Triggers To fire a callback method when a specific setting value updated or created, you can implement `post_save_actions` in `BaseSetting` inherited class Following example shows how to implement `post_save_actions` method. The callback method will be called with following kwargs: ``` key=instance.key value=instance.value created=created # is create operation ``` Note: `post_save_actions` returns an array, so you can add multiple callback methods. These callback methods will be called synchronously. ```python class PostUpdateTestConfiguration(BaseSetting): key = "X_FEATURE_POST_UPDATE" validators = [...] @classmethod def post_save_actions(cls): return [ on_data_updated, ] def on_data_updated(*args, **kwargs): pass ``` ### Testing Tools #### override_settings() You can override a setting for a test method or test class. ```python from dj_dynamic_settings.utils import override_settings from django.test import TestCase @override_settings(SOME_SETTING="some_setting") class FeatureTestCase(TestCase): @override_settings(SOME_OTHER_SETTING="SOME_OTHER_SETTING") def test_feature(self): # Some stuff pass def test_feature_x(self): with override_settings(SOME_OTHER_SETTING="SOME_OTHER_SETTING"): # Some stuff pass ``` %package -n python3-dj-dynamic-settings Summary: Stay informed of it Provides: python-dj-dynamic-settings BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-dj-dynamic-settings # Django Dynamic Settings [![Build status](https://img.shields.io/bitbucket/pipelines/akinonteam/dj-dynamic-settings)](https://bitbucket.org/akinonteam/dj-dynamic-settings/addon/pipelines/home) ![PyPI](https://img.shields.io/pypi/v/dj-dynamic-settings) ![PyPI - Django version](https://img.shields.io/pypi/djversions/dj-dynamic-settings) ![PyPI - Python version](https://img.shields.io/pypi/pyversions/dj-dynamic-settings) ![PyPI - License](https://img.shields.io/pypi/l/dj-dynamic-settings) Django Dynamic Settings allows you to create & use dynamic settings backed by a database. ## Installation Installation using pip: ``` pip install dj-dynamic-settings ``` `dj_dynamic_settings` app has to be added to `INSTALLED_APPS` and `migrate` command has to be run. ```python INSTALLED_APPS = ( # other apps here... "dj_dynamic_settings", ) ``` `dj_dynamic_settings.urls` must be included to a desired url path. ```python urlpatterns = [ ..., url(r"^api/v1/", include("dj_dynamic_settings.urls")), ] ``` Setting class must be defined & registered. Please make sure that this class' module runs whenever the application runs. ```python from dj_dynamic_settings.registry import BaseSetting, registry from dj_dynamic_settings.validators import TypeValidator @registry.register class FeatureActive(BaseSetting): key = "FEATURE_ACTIVE" validators = [TypeValidator(bool)] default = False description = "Flag for Feature X" ``` Create `Setting` instance using view. ```python import requests requests.post( url="https://your-app.com/api/v1/dynamic_settings/", headers={ "Authorization": "Token ", }, json={ "key": "FEATURE_ACTIVE", "value": True, "is_active": True, } ) ``` Access this setting as in `django.conf.settings` ```python from dj_dynamic_settings.conf import settings settings.FEATURE_ACTIVE # True ``` ### Create / Update Triggers To fire a callback method when a specific setting value updated or created, you can implement `post_save_actions` in `BaseSetting` inherited class Following example shows how to implement `post_save_actions` method. The callback method will be called with following kwargs: ``` key=instance.key value=instance.value created=created # is create operation ``` Note: `post_save_actions` returns an array, so you can add multiple callback methods. These callback methods will be called synchronously. ```python class PostUpdateTestConfiguration(BaseSetting): key = "X_FEATURE_POST_UPDATE" validators = [...] @classmethod def post_save_actions(cls): return [ on_data_updated, ] def on_data_updated(*args, **kwargs): pass ``` ### Testing Tools #### override_settings() You can override a setting for a test method or test class. ```python from dj_dynamic_settings.utils import override_settings from django.test import TestCase @override_settings(SOME_SETTING="some_setting") class FeatureTestCase(TestCase): @override_settings(SOME_OTHER_SETTING="SOME_OTHER_SETTING") def test_feature(self): # Some stuff pass def test_feature_x(self): with override_settings(SOME_OTHER_SETTING="SOME_OTHER_SETTING"): # Some stuff pass ``` %package help Summary: Development documents and examples for dj-dynamic-settings Provides: python3-dj-dynamic-settings-doc %description help # Django Dynamic Settings [![Build status](https://img.shields.io/bitbucket/pipelines/akinonteam/dj-dynamic-settings)](https://bitbucket.org/akinonteam/dj-dynamic-settings/addon/pipelines/home) ![PyPI](https://img.shields.io/pypi/v/dj-dynamic-settings) ![PyPI - Django version](https://img.shields.io/pypi/djversions/dj-dynamic-settings) ![PyPI - Python version](https://img.shields.io/pypi/pyversions/dj-dynamic-settings) ![PyPI - License](https://img.shields.io/pypi/l/dj-dynamic-settings) Django Dynamic Settings allows you to create & use dynamic settings backed by a database. ## Installation Installation using pip: ``` pip install dj-dynamic-settings ``` `dj_dynamic_settings` app has to be added to `INSTALLED_APPS` and `migrate` command has to be run. ```python INSTALLED_APPS = ( # other apps here... "dj_dynamic_settings", ) ``` `dj_dynamic_settings.urls` must be included to a desired url path. ```python urlpatterns = [ ..., url(r"^api/v1/", include("dj_dynamic_settings.urls")), ] ``` Setting class must be defined & registered. Please make sure that this class' module runs whenever the application runs. ```python from dj_dynamic_settings.registry import BaseSetting, registry from dj_dynamic_settings.validators import TypeValidator @registry.register class FeatureActive(BaseSetting): key = "FEATURE_ACTIVE" validators = [TypeValidator(bool)] default = False description = "Flag for Feature X" ``` Create `Setting` instance using view. ```python import requests requests.post( url="https://your-app.com/api/v1/dynamic_settings/", headers={ "Authorization": "Token ", }, json={ "key": "FEATURE_ACTIVE", "value": True, "is_active": True, } ) ``` Access this setting as in `django.conf.settings` ```python from dj_dynamic_settings.conf import settings settings.FEATURE_ACTIVE # True ``` ### Create / Update Triggers To fire a callback method when a specific setting value updated or created, you can implement `post_save_actions` in `BaseSetting` inherited class Following example shows how to implement `post_save_actions` method. The callback method will be called with following kwargs: ``` key=instance.key value=instance.value created=created # is create operation ``` Note: `post_save_actions` returns an array, so you can add multiple callback methods. These callback methods will be called synchronously. ```python class PostUpdateTestConfiguration(BaseSetting): key = "X_FEATURE_POST_UPDATE" validators = [...] @classmethod def post_save_actions(cls): return [ on_data_updated, ] def on_data_updated(*args, **kwargs): pass ``` ### Testing Tools #### override_settings() You can override a setting for a test method or test class. ```python from dj_dynamic_settings.utils import override_settings from django.test import TestCase @override_settings(SOME_SETTING="some_setting") class FeatureTestCase(TestCase): @override_settings(SOME_OTHER_SETTING="SOME_OTHER_SETTING") def test_feature(self): # Some stuff pass def test_feature_x(self): with override_settings(SOME_OTHER_SETTING="SOME_OTHER_SETTING"): # Some stuff pass ``` %prep %autosetup -n dj-dynamic-settings-0.2.3 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-dj-dynamic-settings -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Wed Apr 12 2023 Python_Bot - 0.2.3-1 - Package Spec generated