Thank you very much for your fast reply. Our team discussed the solutions we see. At the moment we see this upgrade:
- We stay with the older django version, and don't use atomic for the next months. - We provide a patch for django to provide settings.MIDDLEWARES_INSIDE_TRANSACTION - I hope django will include our patches in a newer version. - If the new version of django is released we can upgrade our code. Explanation: settings.MIDDLEWARES_INSIDE_TRANSACTION=['mymodule.middlewares.HandleChangesOfTransaction', ...] HandleChangesOfTransaction is a class which does some magic at the beginning and end of each transaction. Can you understand what I wrote? Will a patch to provide settings.MIDDLEWARES_INSIDE_TRANSACTION be accepted? Regards, Thomas Güttler Am 03.02.2015 um 11:00 schrieb Aymeric Augustin:
Hi Thomas, Both ways had advantages and drawbacks. Eventually I chose to include only the view function in the transaction for the following reasons. 1) Django never made any guarantees about which process_* methods of middleware would be called. Therefore every middleware must implemented defensively anyway, that is, leave a consistent state regardless of what methods are or aren't called. 2) The goal of ATOMIC_REQUESTS is to prevent inconsistent modifications of the database in views. Since middleware run for every view, they shouldn't introduce inconsistencies no matter what happens. 3) Most middleware don't touch the database. Database queries that run at every request aren't good for overall performance. 4) For lack of a better reason, keeping the database transactions short is more efficient. 1) and 2) really boil down to the fragility of how Django executes middleware. Not including middleware in transactions reduces the risk that developers will make incorrect assumptions. 3) and 4) don't apply to your use case. I looked at how reversion is implemented but I don't understand it sufficiently well to give advice. This isn't a satisfying answer but I hope it helps.
-- Thomas Güttler http://thomas-guettler.de/ -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/54D1EC0C.9070604%40tbz-pariv.de. For more options, visit https://groups.google.com/d/optout.