§ <ˆj» ã óª — d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm Z dd lm Z dd lmZ ddl mZ ddl mZ dd l mZ ddl mZ ddl mZ ddl mZ ddl mZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ g d¢Z! ej" ¦ « Z# d„ Z$ G d„ de%¦ « Z& ej' d¦ « Z( ej' d¦ « Z) ej' d ¦ « Z* ej' d!¦ « Z+ ej' d"¦ « Z, G d#„ d$e%¦ « Z- G d%„ d&e&¦ « Z. G d'„ d(e&¦ « Z/d)„ Z0d*„ Z1d+„ Z2d,„ Z3 ej4 ¦ « Z5dS )-z1Provides the Session class and related utilities.é Né )Ú attributes)Úexc)Úidentity)Úloading)Úpersistence)Úquery©Ústate)Ú_class_to_mapper)Ú _none_set)Ú _state_mapper)Úinstance_str)Ú object_mapper)Úobject_state)Ú state_str)ÚSessionExtension)ÚUOWTransactioné )Úengine)Úsql)Úutil)Úinspect)Ú expression)ÚSessionÚSessionTransactionr Úsessionmakerc óZ — | j r# t | j S # t $ r Y nw xY wdS )z\Given an :class:`.InstanceState`, return the :class:`.Session` associated, if any. N)Ú session_idÚ _sessionsÚKeyErrorr s úM/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/orm/session.pyÚ_state_sessionr# - sG € ð Ôð ð ݘUÔ-Ô.Ð.øÝð ð ð ØˆDð øøøàˆ4s ‰ › (§(c ó® — e Zd ZdZe ej dd¦ « d„ ¦ « ¦ « Ze ej d¦ « d„ ¦ « ¦ « Z ed„ ¦ « Z dS ) Ú_SessionClassMethodszBClass-level methods for :class:`.Session`, :class:`.sessionmaker`.z1.3z’The :meth:`.Session.close_all` method is deprecated and will be removed in a future release. Please refer to :func:`.session.close_all_sessions`.c ó" — t ¦ « dS )zClose *all* sessions in memory.N)Úclose_all_sessions)Úclss r" Ú close_allz_SessionClassMethods.close_all= s € õ ÑÔÐÐÐó zsqlalchemy.orm.utilc ó — |j |i |¤ŽS )zZReturn an identity key. This is an alias of :func:`.util.identity_key`. )Úidentity_key)r( Úorm_utilÚargsÚkwargss r" r, z!_SessionClassMethods.identity_keyI s € ð %ˆxÔ$ dÐ5¨fÐ5Ð5Ð5r* c ó — t |¦ « S )zxReturn the :class:`.Session` to which an object belongs. This is an alias of :func:`.object_session`. )Úobject_session)r( Úinstances r" r1 z#_SessionClassMethods.object_sessionS s € õ ˜hÑ'Ô'Ð'r* N)Ú__name__Ú __module__Ú__qualname__Ú__doc__Úclassmethodr Ú deprecatedr) Údependenciesr, r1 © r* r" r% r% : s¥ € € € € € ØLÐLàØ€T„_Ø ð /ñô ðð ñ ô ñ „[ðð Ø€TÔÐ,Ñ-Ô-ð6ð 6ñ .Ô-ñ „[ð6ð ð(ð (ñ „[ð(ð (ð (r* r% ÚACTIVEÚPREPAREDÚ COMMITTEDÚDEACTIVEÚCLOSEDc óÖ — e Zd ZdZdZdd„Zed„ ¦ « ZdZ ed„ ¦ « Z dd„Z ed „ ¦ « Zdd „Zdd„Z dd„Zd „ Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zdd„Zd„ Zd„ ZdS )r aå A :class:`.Session`-level transaction. :class:`.SessionTransaction` is a mostly behind-the-scenes object not normally referenced directly by application code. It coordinates among multiple :class:`_engine.Connection` objects, maintaining a database transaction for each one individually, committing or rolling them back all at once. It also provides optional two-phase commit behavior which can augment this coordination operation. The :attr:`.Session.transaction` attribute of :class:`.Session` refers to the current :class:`.SessionTransaction` object in use, if any. The :attr:`.SessionTransaction.parent` attribute refers to the parent :class:`.SessionTransaction` in the stack of :class:`.SessionTransaction` objects. If this attribute is ``None``, then this is the top of the stack. If non-``None``, then this :class:`.SessionTransaction` refers either to a so-called "subtransaction" or a "nested" transaction. A "subtransaction" is a scoping concept that demarcates an inner portion of the outermost "real" transaction. A nested transaction, which is indicated when the :attr:`.SessionTransaction.nested` attribute is also True, indicates that this :class:`.SessionTransaction` corresponds to a SAVEPOINT. **Life Cycle** A :class:`.SessionTransaction` is associated with a :class:`.Session` in its default mode of ``autocommit=False`` immediately, associated with no database connections. As the :class:`.Session` is called upon to emit SQL on behalf of various :class:`_engine.Engine` or :class:`_engine.Connection` objects, a corresponding :class:`_engine.Connection` and associated :class:`.Transaction` is added to a collection within the :class:`.SessionTransaction` object, becoming one of the connection/transaction pairs maintained by the :class:`.SessionTransaction`. The start of a :class:`.SessionTransaction` can be tracked using the :meth:`.SessionEvents.after_transaction_create` event. The lifespan of the :class:`.SessionTransaction` ends when the :meth:`.Session.commit`, :meth:`.Session.rollback` or :meth:`.Session.close` methods are called. At this point, the :class:`.SessionTransaction` removes its association with its parent :class:`.Session`. A :class:`.Session` that is in ``autocommit=False`` mode will create a new :class:`.SessionTransaction` to replace it immediately, whereas a :class:`.Session` that's in ``autocommit=True`` mode will remain without a :class:`.SessionTransaction` until the :meth:`.Session.begin` method is called. The end of a :class:`.SessionTransaction` can be tracked using the :meth:`.SessionEvents.after_transaction_end` event. **Nesting and Subtransactions** Another detail of :class:`.SessionTransaction` behavior is that it is capable of "nesting". This means that the :meth:`.Session.begin` method can be called while an existing :class:`.SessionTransaction` is already present, producing a new :class:`.SessionTransaction` that temporarily replaces the parent :class:`.SessionTransaction`. When a :class:`.SessionTransaction` is produced as nested, it assigns itself to the :attr:`.Session.transaction` attribute, and it additionally will assign the previous :class:`.SessionTransaction` to its :attr:`.Session.parent` attribute. The behavior is effectively a stack, where :attr:`.Session.transaction` refers to the current head of the stack, and the :attr:`.SessionTransaction.parent` attribute allows traversal up the stack until :attr:`.SessionTransaction.parent` is ``None``, indicating the top of the stack. When the scope of :class:`.SessionTransaction` is ended via :meth:`.Session.commit` or :meth:`.Session.rollback`, it restores its parent :class:`.SessionTransaction` back onto the :attr:`.Session.transaction` attribute. The purpose of this stack is to allow nesting of :meth:`.Session.rollback` or :meth:`.Session.commit` calls in context with various flavors of :meth:`.Session.begin`. This nesting behavior applies to when :meth:`.Session.begin_nested` is used to emit a SAVEPOINT transaction, and is also used to produce a so-called "subtransaction" which allows a block of code to use a begin/rollback/commit sequence regardless of whether or not its enclosing code block has begun a transaction. The :meth:`.flush` method, whether called explicitly or via autoflush, is the primary consumer of the "subtransaction" feature, in that it wishes to guarantee that it works within in a transaction block regardless of whether or not the :class:`.Session` is in transactional mode when the method is called. Note that the flush process that occurs within the "autoflush" feature as well as when the :meth:`.Session.flush` method is used **always** creates a :class:`.SessionTransaction` object. This object is normally a subtransaction, unless the :class:`.Session` is in autocommit mode and no transaction exists at all, in which case it's the outermost transaction. Any event-handling logic or other inspection logic needs to take into account whether a :class:`.SessionTransaction` is the outermost transaction, a subtransaction, or a "nested" / SAVEPOINT transaction. .. seealso:: :meth:`.Session.rollback` :meth:`.Session.commit` :meth:`.Session.begin` :meth:`.Session.begin_nested` :attr:`.Session.is_active` :meth:`.SessionEvents.after_transaction_create` :meth:`.SessionEvents.after_transaction_end` :meth:`.SessionEvents.after_commit` :meth:`.SessionEvents.after_rollback` :meth:`.SessionEvents.after_soft_rollback` NFc ó — || _ i | _ || _ || _ t | _ |s|rt j d¦ « ‚| j j r| ¦ « | j j | j | ¦ « d S )NzOCan't start a SAVEPOINT transaction when no existing transaction is in progress)ÚsessionÚ_connectionsÚ_parentÚnestedr; Ú_stateÚsa_excÚInvalidRequestErrorÚ_enable_transaction_accountingÚ_take_snapshotÚdispatchÚafter_transaction_create)ÚselfrB ÚparentrE s r" Ú__init__zSessionTransaction.__init__Ý s“ € ؈ŒØˆÔ؈ŒØˆŒÝˆŒØð ˜&ð