#NEWLINE# def begin( self , subtransactions = False , nested = False ) : #NEWLINE# #INDENT# 'Begin a transaction on this :class:`.Session`.\n\n        If this Session is already within a transaction, either a plain\n        transaction or nested transaction, an error is raised, unless\n        ``subtransactions=True`` or ``nested=True`` is specified.\n\n        The ``subtransactions=True`` flag indicates that this\n        :meth:`~.Session.begin` can create a subtransaction if a transaction\n        is already in progress. For documentation on subtransactions, please\n        see :ref:`session_subtransactions`.\n\n        The ``nested`` flag begins a SAVEPOINT transaction and is equivalent\n        to calling :meth:`~.Session.begin_nested`. For documentation on\n        SAVEPOINT transactions, please see :ref:`session_begin_nested`.\n\n        ' #NEWLINE# if ( self . transaction is not None ) : #NEWLINE# #INDENT# if ( subtransactions or nested ) : #NEWLINE# #INDENT# self . transaction = self . transaction . _begin ( nested = nested ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise sa_exc . InvalidRequestError ( 'A transaction is already begun.  Use subtransactions=True to allow subtransactions.' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . transaction = SessionTransaction ( self , nested = nested ) #NEWLINE# #UNINDENT# return self . transaction