mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-03-16 22:20:27 +00:00
Only run __init__ in __new__ when late binding is enabled.
Signed-off-by: Jannis Leidel <jannis@leidel.info>
This commit is contained in:
parent
e09e1e0f42
commit
5ece107044
1 changed files with 5 additions and 6 deletions
|
|
@ -47,18 +47,17 @@ class Value(object):
|
|||
That is the case whenever environ = False or environ_name is given.
|
||||
"""
|
||||
instance = object.__new__(cls)
|
||||
instance.__init__(*args, **kwargs)
|
||||
if 'late_binding' in kwargs:
|
||||
instance.late_binding = kwargs.get('late_binding')
|
||||
if not instance.late_binding:
|
||||
if (instance.environ and instance.environ_name) \
|
||||
or (not instance.environ and instance.default):
|
||||
instance.__init__(*args, **kwargs)
|
||||
if ((instance.environ and instance.environ_name) or
|
||||
(not instance.environ and instance.default)):
|
||||
instance = instance.setup(instance.environ_name)
|
||||
|
||||
return instance
|
||||
|
||||
def __init__(self, default=None, environ=True, environ_name=None,
|
||||
environ_prefix='DJANGO', *args, **kwargs):
|
||||
if 'late_binding' in kwargs:
|
||||
self.late_binding = kwargs.get('late_binding')
|
||||
if isinstance(default, Value) and default.default is not None:
|
||||
self.default = copy.copy(default.default)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue