'Begin a transaction on this Session.
If this Session is already within a transaction, either a plain
transaction or nested transaction, an error is raised, unless
``subtransactions=True`` or ``nested=True`` is specified.
The ``subtransactions=True`` flag indicates that this
:meth:`~.Session.begin` can create a subtransaction if a transaction
is already in progress. For documentation on subtransactions, please
see :ref:`session_subtransactions`.
The ``nested`` flag begins a SAVEPOINT transaction and is equivalent
to calling :meth:`~.Session.begin_nested`. For documentation on
SAVEPOINT transactions, please see :ref:`session_begin_nested`.'

def begin(self, subtransactions=False, nested=False):

    if (self.transaction is not None):
        if (subtransactions or nested):
            self.transaction = self.transaction._begin(nested=nested)
        else:
            raise sa_exc.InvalidRequestError('A    transaction    is    already    begun.        Use    subtransactions=True    to    allow    subtransactions.')
    else:
        self.transaction = SessionTransaction(self, nested=nested)
    return self.transaction
