Code

Ticket #2304: fixed_transaction_settings_variable_name.diff

File fixed_transaction_settings_variable_name.diff, 2.1 KB (added by tjshewmake, 4 years ago)

Proposed fix of manual transactions variable name.

Line 
1Index: db/transaction.py
2===================================================================
3--- db/transaction.py   (revision 13362)
4+++ db/transaction.py   (working copy)
5@@ -61,7 +61,16 @@
6         state[thread_ident][using].append(state[thread_ident][using][-1])
7     else:
8         state.setdefault(thread_ident, {})
9-        state[thread_ident][using] = [settings.TRANSACTIONS_MANAGED]
10+        if hasattr(settings, 'TRANSACTIONS_MANAGED'):
11+            state[thread_ident][using] = [settings.TRANSACTIONS_MANAGED]
12+            warnings.warn(
13+                '`settings.TRANSACTIONS_MANAGED` is deprecated. '
14+                'Please update your code to use DISABLE_TRANSACTION_MANAGEMENT.',
15+                PendingDeprecationWarning
16+            )
17+        else:
18+            state[thread_ident][using] = [settings.DISABLE_TRANSACTION_MANAGEMENT]
19+
20     if thread_ident not in dirty or using not in dirty[thread_ident]:
21         dirty.setdefault(thread_ident, {})
22         dirty[thread_ident][using] = False
23@@ -142,7 +151,15 @@
24     if thread_ident in state and using in state[thread_ident]:
25         if state[thread_ident][using]:
26             return state[thread_ident][using][-1]
27-    return settings.TRANSACTIONS_MANAGED
28+    if hasattr(settings, 'TRANSACTIONS_MANAGED'):
29+        warnings.warn(
30+            '`settings.TRANSACTIONS_MANAGED` is deprecated. '
31+            'Please update your code to use DISABLE_TRANSACTION_MANAGEMENT.',
32+            PendingDeprecationWarning
33+        )
34+        return settings.TRANSACTIONS_MANAGED
35+    else:
36+        return settings.DISABLE_TRANSACTION_MANAGEMENT
37 
38 def managed(flag=True, using=None):
39     """
40Index: conf/global_settings.py
41===================================================================
42--- conf/global_settings.py     (revision 13362)
43+++ conf/global_settings.py     (working copy)
44@@ -378,7 +378,7 @@
45 
46 # Do you want to manage transactions manually?
47 # Hint: you really don't!
48-TRANSACTIONS_MANAGED = False
49+DISABLE_TRANSACTION_MANAGEMENT = False
50 
51 # The User-Agent string to use when checking for URL validity through the
52 # isExistingURL validator.