benjaoming/django-wiki — pull request #241 by spookylukey (2014-02-04 10:11:25+00:00)
Title: Fix transaction management - issue #225

All uses of transaction management are fixed. The approach taken is to make it future proof, using the new "atomic" decorator, and bringing behaviour on Django 1.5 in line with that by using the "commit_on_success" decorator. All "atomic" blocks are moved to the model layer.

Note the fact that DB exceptions must not be handled inside the atomic block: https://docs.djangoproject.com/en/dev/topics/db/transactions/#django.db.transaction.atomic
This forced my hand in terms of the right approach to take.

It is hard to test the error cases automatically, but I have tested them manually, (by inserting some code that raises an exception part way through the atomic blocks, after a save), and I tested it with ATOMIC_REQUESTS on and off, and using the Django 1.5 method (commit_on_success).

This branch includes various fixes to make it easier to run tests, which I needed to do a lot.