Nested commit_on_success
This is a simple modification to the standard transaction.commit_on_success decorator that is aware of existing transactions. If a managed transaction is already active then the wrapped function is called directly, assuming the active transaction will clean up as appropriate. Otherwise, a standard commit_on_success is performed. I'm using this to wrap the save() method of models that manipulate other related models on save, e.g: @nested_commit_on_success def save(self): super(MyClass,self).save() for m in other_models: self.fix_up_other_model(m) m.save()
- transaction