@contextmanager<EOL><INDENT>def transaction(self, connection=None, **kwargs):<DEDENT>
with self.connection(connection) as connection:<EOL><INDENT>name = connection.transaction_name()<EOL>connection.transaction_start(name)<EOL>try:<EOL><INDENT>yield connection<EOL>connection.transaction_stop()<EOL><DEDENT>except Exception as e:<EOL><INDENT>connection.transaction_fail(name)<EOL>self.raise_error(e)<EOL><DEDENT><DEDENT>
a simple context manager useful for when you want to wrap a bunch of db calls in a transaction
http://docs.python.org/2/library/contextlib.html
http://docs.python.org/release/2.5/whatsnew/pep-343.html

example --
    with self.transaction()
        # do a bunch of calls
    # those db calls will be committed by this line