﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10771	Add a transaction context manager	Oliver Beattie	nobody	"For users who use transactions heavily, it is sometimes desirable to be able to wrap parts of a function (but not all of it) in a transaction of its own. Previously, the best way to do this was either to do it manually with a `try…except…else` block or creating a sub-function wrapped in `commit_on_success`, but context managers in Python 2.5+ can make this much cleaner by just saying…

{{{
with transaction:
    # do stuff
}}}

…which will handle committing and rolling back. Attached is a patch that I'd love to see implemented in Django :) The function is extremely similar to `commit_on_success` (the structure is identical)."		closed	Database layer (models, ORM)	dev		fixed	transaction, contextmanager	Henrique Romano	Accepted	1	0	0	0	0	0
