-
-
Notifications
You must be signed in to change notification settings - Fork 863
/
base.py
24 lines (19 loc) · 766 Bytes
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from django.core.exceptions import ImproperlyConfigured
from django.core.files.storage import Storage
class BaseStorage(Storage):
def __init__(self, **settings):
default_settings = self.get_default_settings()
for name, value in default_settings.items():
if not hasattr(self, name):
setattr(self, name, value)
for name, value in settings.items():
if name not in default_settings:
raise ImproperlyConfigured(
"Invalid setting '{}' for {}".format(
name,
self.__class__.__name__,
)
)
setattr(self, name, value)
def get_default_settings(self):
return {}