|
@@ -0,0 +1,37 @@
|
|
1
|
+#-*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+import settings_local
|
|
4
|
+
|
|
5
|
+class Settings:
|
|
6
|
+ # List of accepted settings
|
|
7
|
+ datasource = None
|
|
8
|
+
|
|
9
|
+ @staticmethod
|
|
10
|
+ # @throw AttributeError if the setting is not defined in this class
|
|
11
|
+ def get(attribute):
|
|
12
|
+ value = None
|
|
13
|
+ # find the value in settings itself, if not set search in settings_local
|
|
14
|
+ value = getattr(Settings, attribute)
|
|
15
|
+ if value is None:
|
|
16
|
+ try:
|
|
17
|
+ value = getattr(settings_local, attribute)
|
|
18
|
+ except AttributeError:
|
|
19
|
+ pass
|
|
20
|
+
|
|
21
|
+ if value is not None:
|
|
22
|
+ try:
|
|
23
|
+ func = getattr(Settings, attribute + '_args')
|
|
24
|
+ value = func(value)
|
|
25
|
+ except AttributeError:
|
|
26
|
+ pass
|
|
27
|
+
|
|
28
|
+ return value
|
|
29
|
+
|
|
30
|
+ @staticmethod
|
|
31
|
+ # @throw AttributeError if the setting is not defined in this class
|
|
32
|
+ def set(attribute, value):
|
|
33
|
+ setattr(Settings, attribute, value)
|
|
34
|
+
|
|
35
|
+ @staticmethod
|
|
36
|
+ def datasource_args(value):
|
|
37
|
+ return value
|