File: //opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/orm/__pycache__/state.cpython-37.pyc
B
��4]Dy � @ 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 @ sN e Zd ZdZdZdZdZejZ dZ
dZdZdZ
dZdZdZdZdZdZdZdZdd� ZdZejdd � �Zed
d� �Zedd
� �Zedd� �Zedd� �Zedd� �Zedd� �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.�Z.d/d0� Z/d1d2� Z0d3d4� Z1ed5d6� �Z2d7d8� Z3d9d:� Z4d;d<� Z5d=d>� Z6d?d@� Z7dAdB� Z8dCdD� Z9dEdF� Z:e,dGdH� �Z;dIdJ� Z<dedKdL�Z=dMdN� Z>edOdP� �Z?dQdR� Z@edSdT� �ZAedUdV� �ZBedWdX� �ZCdYdZ� ZDdfd[d\�ZEd]d^� ZFdgd_d`�ZGe,dhdadb��ZHdS )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:`.inspect` system::
>>> from sqlalchemy import inspect
>>> insp = inspect(some_mapped_object)
.. seealso::
:ref:`core_inspection_toplevel`
N� FTc 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 �G/opt/alt/python37/lib64/python3.7/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 )N)�AttributeState)�.0�key)r r r � <genexpr>u s z&InstanceState.attrs.<locals>.<genexpr>)r ZImmutableProperties�dictr )r r )r r �attrsh s zInstanceState.attrsc C s | j dko| j S )zyReturn true if the object is :term:`transient`.
.. seealso::
:ref:`session_object_states`
N)r# � _attached)r r r r � transientx s zInstanceState.transientc C s | j dko| jS )zxReturn true if the object is :term:`pending`.
.. seealso::
:ref:`session_object_states`
N)r# r'