mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-03-16 22:20:27 +00:00
Renamed the pristine decorator to pristinemethod for consistency.
This commit is contained in:
parent
df865840bc
commit
708fb9ac50
4 changed files with 16 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# flake8: noqa
|
||||
from .base import Settings
|
||||
from .decorators import pristine
|
||||
from .decorators import pristinemethod
|
||||
|
||||
__version__ = '0.2.1'
|
||||
__all__ = ['Settings', 'pristine']
|
||||
__all__ = ['Settings', 'pristinemethod']
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
def pristine(func):
|
||||
def pristinemethod(func):
|
||||
"""
|
||||
A decorator for handling pristine settings like callables.
|
||||
|
||||
Use it like this::
|
||||
|
||||
from configurations import pristine
|
||||
from configurations import pristinemethod
|
||||
|
||||
class Develop(Settings):
|
||||
|
||||
@pristine
|
||||
@pristinemethod
|
||||
USER_CHECK(user):
|
||||
return user.check_perms()
|
||||
|
||||
GROUP_CHECK = pristine(lambda user: user.has_group_access())
|
||||
GROUP_CHECK = pristinemethod(lambda user: user.has_group_access())
|
||||
|
||||
"""
|
||||
func.pristine = True
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
import uuid
|
||||
from configurations import Settings, pristine
|
||||
from configurations import Settings, pristinemethod
|
||||
|
||||
|
||||
class Test(Settings):
|
||||
|
|
@ -47,9 +47,9 @@ class Test(Settings):
|
|||
|
||||
LAMBDA_SETTING = lambda self: 3
|
||||
|
||||
PRISTINE_LAMBDA_SETTING = pristine(lambda: 4)
|
||||
PRISTINE_LAMBDA_SETTING = pristinemethod(lambda: 4)
|
||||
|
||||
@pristine
|
||||
@pristinemethod
|
||||
def PRISTINE_FUNCTION_SETTING():
|
||||
return 5
|
||||
|
||||
|
|
|
|||
|
|
@ -131,29 +131,29 @@ a Settings class::
|
|||
DEBUG = False
|
||||
# ...
|
||||
|
||||
Pristines
|
||||
^^^^^^^^^
|
||||
Pristine methods
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
.. versionadded:: 0.3
|
||||
|
||||
In case one of your settings itself need to be a callable, you need to
|
||||
tell that django-configurations by using the ``pristine`` decorator,
|
||||
tell that django-configurations by using the ``pristinemethod`` decorator,
|
||||
e.g.::
|
||||
|
||||
from configurations import Settings, pristine
|
||||
from configurations import Settings, pristinemethod
|
||||
|
||||
class Prod(Settings):
|
||||
|
||||
@pristine
|
||||
@pristinemethod
|
||||
def ACCESS_FUNCTION(user):
|
||||
return user.is_staff
|
||||
|
||||
Lambdas work, too::
|
||||
|
||||
from configurations import Settings, pristine
|
||||
from configurations import Settings, pristinemethod
|
||||
|
||||
class Prod(Settings):
|
||||
ACCESS_FUNCTION = pristine(lamda user: user.is_staff)
|
||||
ACCESS_FUNCTION = pristinemethod(lamda user: user.is_staff)
|
||||
|
||||
Setup methods
|
||||
^^^^^^^^^^^^^
|
||||
|
|
|
|||
Loading…
Reference in a new issue