ATOMIC_REQUESTS Middleware inside Transaction

38 views
Skip to first unread message

guettli

unread,
Aug 11, 2015, 3:24:37 AM8/11/15
to Django users
I am not happy that settings.ATOMIC_REQUESTS=True isolates only the view, but not the middlewares
in one transaction.

For applications like reversion (app which records the changes of a model) it is very important,
that the middleware runs inside the same transaction. If storing the changes
runs in a second transaction, inconsistencies will happen: Model got updated,
but storing the changes in the second transaction might fail.

We are in the process of updating our apps to Django 1.8.

At the moment our preferred solution:

 - set settings.ATOMIC_REQUESTS=False
 - Run an own middleware which starts and ends the transaction.

Nearly two years ago this kind of Middleware suggested in this list:

https://groups.google.com/forum/#!msg/django-users/njeVp4zT5HA/9g0wsFYZKAwJ

Related issue for app reversion: https://github.com/etianen/django-reversion/issues/268

What do you think?


guettli

unread,
Aug 20, 2015, 3:54:20 AM8/20/15
to Django users
Sad, not reply since nine days ...
Is there something you don't understand? Please ask :-)

Tim Graham

unread,
Aug 20, 2015, 12:57:37 PM8/20/15
to Django users
I'm not sure what type of reply or answer you are looking for.

Overhauling Django middleware as discussed on the developers mailing list might be best in the long run.
https://groups.google.com/d/topic/django-developers/uW5Ogio8QBc/discussion
Reply all
Reply to author
Forward
0 new messages