2
2
3
3
from django .core .exceptions import ImproperlyConfigured
4
4
from django .test .signals import setting_changed
5
+ from django .utils .module_loading import import_string
5
6
6
7
from .compat import get_callable
7
8
8
9
# List Editable Policy
9
10
# 0 do not save updated records, save others, show message to the user
10
11
# 1 abort whole transaction
12
+ from . import triggers
13
+ from .utils import fqn
11
14
12
15
CONCURRENCY_LIST_EDITABLE_POLICY_SILENT = 1
13
16
CONCURRENCY_LIST_EDITABLE_POLICY_ABORT_ALL = 2
@@ -27,6 +30,11 @@ class AppSettings(object):
27
30
'CALLBACK' : 'concurrency.views.callback' ,
28
31
'HANDLER409' : 'concurrency.views.conflict' ,
29
32
'VERSION_FIELD_REQUIRED' : True ,
33
+ 'TRIGGER_FACTORIES' : {'postgresql' : fqn (triggers .PostgreSQL ),
34
+ 'mysql' : fqn (triggers .MySQL ),
35
+ 'sqlite3' : fqn (triggers .Sqlite3 ),
36
+ 'sqlite' : fqn (triggers .Sqlite3 ),
37
+ }
30
38
}
31
39
32
40
def __init__ (self , prefix ):
@@ -65,6 +73,13 @@ def _set_attr(self, prefix_name, value):
65
73
warnings .warn ("MANUAL_TRIGGERS is deprecated and will be removed in 2.5. Use AUTO_CREATE_TRIGGERS" ,
66
74
category = DeprecationWarning )
67
75
self .AUTO_CREATE_TRIGGERS = not value
76
+ elif name == "TRIGGER_FACTORIES" :
77
+ self .TRIGGER_FACTORIES = {}
78
+ for k , v in value .items ():
79
+ try :
80
+ self .TRIGGER_FACTORIES [k ] = import_string (v )
81
+ except ImportError :
82
+ raise ImproperlyConfigured (f"Unable to load { k } TriggerFactory. Invalid fqn { v } " )
68
83
69
84
setattr (self , name , value )
70
85
0 commit comments