I am developing a course registration website. A user can enroll in a class, during which he/she incurs an enrollment fee for that class:
class.add(student);
student.get_profile().balance += class.tuition
How do I make sure that these two operations are atomic? For instance, I do not want the second action to be performed if the first action failed to be performed (due to say overuse of memory).
Django transaction Middleware would allow you to do so.