
    Zh0                         d dl mZ  G d d          Z G d de          Z G d de          Z G d d	e          Zd
S )   )excc                   n    e Zd ZdZd Zed             Zed             Zd Zd Z	d Z
d Zd	 Zd
 Zd ZdS )Transactiona  Represent a database transaction in progress.

    The Transaction object is procured by
    calling the SAConnection.begin() method of
    SAConnection:

        with (yield from engine) as conn:
            trans = yield from conn.begin()
            try:
                yield from conn.execute("insert into x (a, b) values (1, 2)")
            except Exception:
                yield from trans.rollback()
            else:
                yield from trans.commit()

    The object provides .rollback() and .commit()
    methods in order to control transaction boundaries.

    See also:  SAConnection.begin(), SAConnection.begin_twophase(),
    SAConnection.begin_nested().
    c                 4    || _         |p| | _        d| _        d S )NT)_connection_parent
_is_active)self
connectionparents      d/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/aiomysql/sa/transaction.py__init__zTransaction.__init__   s     %~    c                     | j         S )z+Return ``True`` if a transaction is active.)r	   r
   s    r   	is_activezTransaction.is_active"   s     r   c                     | j         S )z8Return transaction's connection (SAConnection instance).)r   r   s    r   r   zTransaction.connection'   s     r   c                 ~   K   | j         j        sdS | j         | u r|                                  d{V  dS d| _        dS )a0  Close this transaction.

        If this transaction is the base transaction in a begin/commit
        nesting, the transaction will rollback().  Otherwise, the
        method returns.

        This is used to cancel a Transaction without affecting the scope of
        an enclosing transaction.
        NF)r   r	   rollbackr   s    r   closezTransaction.close,   sX       |& 	F<4--//!!!!!!!!!#DOOOr   c                 h   K   | j         j        sdS |                                  d{V  d| _        dS )zRoll back this transaction.NF)r   r	   _do_rollbackr   s    r   r   zTransaction.rollback=   sG      |& 	F!!!!!!!!!r   c                 H   K   | j                                          d {V  d S N)r   r   r   s    r   r   zTransaction._do_rollbackD   s2      l##%%%%%%%%%%%r   c                    K   | j         j        st          j        d          |                                  d{V  d| _        dS )zCommit this transaction.This transaction is inactiveNF)r   r	   r   InvalidRequestError
_do_commitr   s    r   commitzTransaction.commitG   sU       |& 	J)*HIIIoor   c                 
   K   d S r    r   s    r   r   zTransaction._do_commitO   s      r   c                 
   K   | S r   r!   r   s    r   
__aenter__zTransaction.__aenter__R   s      r   c                    K   |r|                                   d {V  d S | j        r|                                  d {V  d S d S r   )r   r	   r   )r
   exc_typeexc_valexc_tbs       r   	__aexit__zTransaction.__aexit__U   sn       	$--//!!!!!!!!! $kkmm#########$ $r   N)__name__
__module____qualname____doc__r   propertyr   r   r   r   r   r   r   r#   r(   r!   r   r   r   r      s         ,  
   X     X $ $ $"     & & &         $ $ $ $ $r   r   c                   *     e Zd Z fdZd Zd Z xZS )RootTransactionc                 L    t                                          |d            d S r   superr   )r
   r   	__class__s     r   r   zRootTransaction.__init___   s#    T*****r   c                 H   K   | j                                          d {V  d S r   )r   _rollback_implr   s    r   r   zRootTransaction._do_rollbackb   s3      --///////////r   c                 H   K   | j                                          d {V  d S r   )r   _commit_implr   s    r   r   zRootTransaction._do_commite   s3      ++-----------r   )r)   r*   r+   r   r   r   __classcell__r3   s   @r   r/   r/   ]   sV        + + + + +0 0 0. . . . . . .r   r/   c                   2     e Zd ZdZdZ fdZd Zd Z xZS )NestedTransactionzRepresent a 'nested', or SAVEPOINT transaction.

    A new NestedTransaction object may be procured
    using the SAConnection.begin_nested() method.

    The interface is the same as that of Transaction class.
    Nc                 L    t                                          ||           d S r   r1   )r
   r   r   r3   s      r   r   zNestedTransaction.__init__t   s#    V,,,,,r   c                    K   | j         
J d            | j        r-| j                            | j         | j                   d {V  d S d S NzBroken transaction logic)
_savepointr	   r   _rollback_to_savepoint_implr   r   s    r   r   zNestedTransaction._do_rollbackw   s}      **,F***? 	/">>/ / / / / / / / / / /	/ 	/r   c                    K   | j         
J d            | j        r-| j                            | j         | j                   d {V  d S d S r>   )r?   r	   r   _release_savepoint_implr   r   s    r   r   zNestedTransaction._do_commit}   s}      **,F***? 	/"::/ / / / / / / / / / /	/ 	/r   )	r)   r*   r+   r,   r?   r   r   r   r8   r9   s   @r   r;   r;   i   sg          J- - - - -/ / // / / / / / /r   r;   c                   J     e Zd ZdZ fdZed             Zd Zd Zd Z	 xZ
S )TwoPhaseTransactionzRepresent a two-phase transaction.

    A new TwoPhaseTransaction object may be procured
    using the SAConnection.begin_twophase() method.

    The interface is the same as that of Transaction class
    with the addition of the .prepare() method.
    c                 h    t                                          |d            d| _        || _        d S )NF)r2   r   _is_prepared_xid)r
   r   xidr3   s      r   r   zTwoPhaseTransaction.__init__   s0    T***!			r   c                     | j         S )z Returns twophase transaction id.)rG   r   s    r   rH   zTwoPhaseTransaction.xid   s     yr   c                    K   | j         j        st          j        d          | j                            | j                   d{V  d| _        dS )zfPrepare this TwoPhaseTransaction.

        After a PREPARE, the transaction can be committed.
        r   NT)r   r   r   r   r   _prepare_twophase_implrG   rF   r   s    r   preparezTwoPhaseTransaction.prepare   sa       |% 	J)*HIII55di@@@@@@@@@ r   c                 b   K   | j                             | j        | j                   d {V  d S N)is_prepared)r   rollback_preparedrG   rF   r   s    r   r   z TwoPhaseTransaction._do_rollback   sX      00I4#4 1 6 6 	6 	6 	6 	6 	6 	6 	6 	6 	6r   c                 b   K   | j                             | j        | j                   d {V  d S rN   )r   commit_preparedrG   rF   r   s    r   r   zTwoPhaseTransaction._do_commit   sX      ..I4#4 / 6 6 	6 	6 	6 	6 	6 	6 	6 	6 	6r   )r)   r*   r+   r,   r   r-   rH   rL   r   r   r8   r9   s   @r   rD   rD      s             
   X	! 	! 	!6 6 66 6 6 6 6 6 6r   rD   N) r   r   r/   r;   rD   r!   r   r   <module>rT      s         T$ T$ T$ T$ T$ T$ T$ T$n	. 	. 	. 	. 	.k 	. 	. 	./ / / / / / / /6%6 %6 %6 %6 %6+ %6 %6 %6 %6 %6r   