Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/sqlalchemy/orm/__pycache__/state.cpython-39.pyc
Ðазад
a _�h[x � @ s� d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd lm Z dd lm Z ddlmZ ddlmZ dd lm Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ejG dd� dej��ZG dd� de�ZG dd� de�ZdS )z�Defines instrumentation of instances. This module is usually not directly visible to user applications, but defines a large part of the ORM's interactivity. � N� )�base)�exc)� interfaces)�ATTR_WAS_SET)�INIT_OK)� NEVER_SET)�NO_VALUE)�PASSIVE_NO_INITIALIZE)�PASSIVE_NO_RESULT)�PASSIVE_OFF)�SQL_OK)�PathRegistry� )� inspection)�utilc @ sP e Zd ZdZdZdZdZejZ e jZdZ dZdZdZdZdZdZdZdZdZdZdd� ZdZejdd � �Zed d� �Zedd � �Zedd� �Zedd� �Z edd� �Z!edd� �Z"ee�#d�dd� ��Z$dd� Z%ee�#d�dd� ��Z&edd� �Z'edd � �Z(ed!d"� �Z)ejd#d$� �Z*ejd%d&� �Z+ejd'd(� �Z,ed)d*� �Z-e.dcd+d,��Z/ddd-d.�Z0d/d0� Z1d1d2� Z2d3d4� Z3ed5d6� �Z4d7d8� Z5d9d:� Z6d;d<� Z7d=d>� Z8d?d@� Z9dAdB� Z:dCdD� Z;dEdF� Z<e.dGdH� �Z=dIdJ� Z>dedKdL�Z?dMdN� Z@edOdP� �ZAdQdR� ZBedSdT� �ZCedUdV� �ZDedWdX� �ZEdYdZ� ZFdfd[d\�ZGd]d^� ZHdgd_d`�ZIe.dhdadb��ZJdS )i� InstanceStatea� tracks state information at the instance level. The :class:`.InstanceState` is a key object used by the SQLAlchemy ORM in order to track the state of an object; it is created the moment an object is instantiated, typically as a result of :term:`instrumentation` which SQLAlchemy applies to the ``__init__()`` method of the class. :class:`.InstanceState` is also a semi-public object, available for runtime inspection as to the state of a mapped instance, including information such as its current status within a particular :class:`.Session` and details about data on individual attributes. The public API in order to acquire a :class:`.InstanceState` object is to use the :func:`_sa.inspect` system:: >>> from sqlalchemy import inspect >>> insp = inspect(some_mapped_object) .. seealso:: :ref:`core_inspection_toplevel` NFT� c C s0 |j | _|| _t�|| j�| _i | _t� | _ d S �N) � __class__�class_�manager�weakref�ref�_cleanup�obj�committed_state�set�expired_attributes)�selfr r r r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/sqlalchemy/orm/state.py�__init__Y s zInstanceState.__init__c s t �t� fdd�� jD ���S )aa Return a namespace representing each attribute on the mapped object, including its current value and history. The returned object is an instance of :class:`.AttributeState`. This object allows inspection of the current data within an attribute as well as attribute history since the last flush. c 3 s | ]}|t � |�fV qd S r )�AttributeState)�.0�key�r r r � <genexpr>u � z&InstanceState.attrs.<locals>.<genexpr>)r ZImmutableProperties�dictr r% r r% r �attrsh s �zInstanceState.attrsc C s | j du o| j S )z}Return ``True`` if the object is :term:`transient`. .. seealso:: :ref:`session_object_states` N�r$ � _attachedr% r r r � transientx s zInstanceState.transientc C s | j du o| jS )z|Return ``True`` if the object is :term:`pending`. .. seealso:: :ref:`session_object_states` Nr* r% r r r �pending� s zInstanceState.pendingc C s | j duo| jo| jS )a� Return ``True`` if the object is :term:`deleted`. An object that is in the deleted state is guaranteed to not be within the :attr:`.Session.identity_map` of its parent :class:`.Session`; however if the session's transaction is rolled back, the object will be restored to the persistent state and the identity map. .. note:: The :attr:`.InstanceState.deleted` attribute refers to a specific state of the object that occurs between the "persistent" and "detached" states; once the object is :term:`detached`, the :attr:`.InstanceState.deleted` attribute **no longer returns True**; in order to detect that a state was deleted, regardless of whether or not the object is associated with a :class:`.Session`, use the :attr:`.InstanceState.was_deleted` accessor. .. versionadded: 1.1 .. seealso:: :ref:`session_object_states` N�r$ r+ �_deletedr% r r r �deleted� s zInstanceState.deletedc C s | j S )a� Return True if this object is or was previously in the "deleted" state and has not been reverted to persistent. This flag returns True once the object was deleted in flush. When the object is expunged from the session either explicitly or via transaction commit and enters the "detached" state, this flag will continue to report True. .. versionadded:: 1.1 - added a local method form of :func:`.orm.util.was_deleted`. .. seealso:: :attr:`.InstanceState.deleted` - refers to the "deleted" state :func:`.orm.util.was_deleted` - standalone function :ref:`session_object_states` )r/ r% r r r �was_deleted� s zInstanceState.was_deletedc C s | j duo| jo| j S )a{ Return ``True`` if the object is :term:`persistent`. An object that is in the persistent state is guaranteed to be within the :attr:`.Session.identity_map` of its parent :class:`.Session`. .. versionchanged:: 1.1 The :attr:`.InstanceState.persistent` accessor no longer returns True for an object that was "deleted" within a flush; use the :attr:`.InstanceState.deleted` accessor to detect this state. This allows the "persistent" state to guarantee membership in the identity map. .. seealso:: :ref:`session_object_states` Nr. r% r r r � persistent� s zInstanceState.persistentc C s | j duo| j S )z|Return ``True`` if the object is :term:`detached`. .. seealso:: :ref:`session_object_states` Nr* r% r r r �detached� s zInstanceState.detachedzsqlalchemy.orm.sessionc C s | j d uo| j |jv S r )� session_idZ _sessions�r Z sessionlibr r r r+ � s �zInstanceState._attachedc C s$ || j vr t| j �| _ t| j |<