6
6
from django .db import DEFAULT_DB_ALIAS
7
7
from django .db .backends .base .base import BaseDatabaseWrapper
8
8
from django .db .backends .utils import debug_transaction
9
- from django .db .transaction import TransactionManagementError
10
9
from django .utils .asyncio import async_unsafe
11
10
from django .utils .functional import cached_property
12
11
from pymongo .collection import Collection
@@ -247,11 +246,6 @@ def close_pool(self):
247
246
def cursor (self ):
248
247
return Cursor ()
249
248
250
- def validate_no_atomic_block (self ):
251
- """Raise an error if an atomic block is active."""
252
- if self .in_atomic_block_mongo :
253
- raise TransactionManagementError ("This is forbidden when an 'atomic' block is active." )
254
-
255
249
def get_database_version (self ):
256
250
"""Return a tuple of the database's version."""
257
251
return tuple (self .connection .server_info ()["versionArray" ])
@@ -263,28 +257,19 @@ def _start_transaction(self):
263
257
self .session .start_transaction ()
264
258
265
259
def commit_mongo (self ):
266
- self .validate_thread_sharing ()
267
- self .validate_no_atomic_block ()
268
260
if self .session :
269
261
with debug_transaction (self , "session.commit_transaction()" ):
270
262
self .session .commit_transaction ()
271
263
self ._end_session ()
272
- # A successful commit means that the database connection works.
273
- self .errors_occurred = False
274
264
self .run_commit_hooks_on_set_autocommit_on = True
275
265
276
266
@async_unsafe
277
267
def rollback_mongo (self ):
278
268
"""Roll back a MongoDB transaction and reset the dirty flag."""
279
- self .validate_thread_sharing ()
280
- self .validate_no_atomic_block ()
281
269
if self .session :
282
270
with debug_transaction (self , "session.abort_transaction()" ):
283
271
self .session .abort_transaction ()
284
272
self ._end_session ()
285
- # A successful rollback means that the database connection works.
286
- self .errors_occurred = False
287
- self .needs_rollback_mongo = False
288
273
self .run_on_commit = []
289
274
290
275
def _end_session (self ):
0 commit comments