File: //opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/orm/__pycache__/state.cpython-311.pyc
�
    � h[x  �                   �>  � d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lm	Z	 dd
lm
Z
 ddlmZ ddlmZ dd
lm
Z
 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ej         G d� dej        �  �        �   �         Z G d� de�  �        Z G d� 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                   �  � e Zd ZdZdZdZdZej        Z	e
j        ZdZ
dZdZdZdZdZdZdZdZdZdZ	 d� ZdZ	 ej        d� �   �         Zed� �   �         Zed	� �   �         Zed
� �   �         Zed� �   �         Z ed� �   �         Z!ed
� �   �         Z"e ej#        d�  �        d� �   �         �   �         Z$d� Z%e ej#        d�  �        d� �   �         �   �         Z&ed� �   �         Z'ed� �   �         Z(ed� �   �         Z)ej        d� �   �         Z*ej        d� �   �         Z+ej        d� �   �         Z,ed� �   �         Z-e.d5d��   �         Z/d6d�Z0d� Z1d� Z2d� Z3ed� �   �         Z4d� Z5d � Z6d!� Z7d"� Z8d#� Z9d$� Z:d%� Z;d&� Z<e.d'� �   �         Z=d(� Z>d5d)�Z?d*� Z@ed+� �   �         ZAd,� ZBed-� �   �         ZCed.� �   �         ZDed/� �   �         ZEd0� ZF	 d7d1�ZGd2� ZHd6d3�ZIe.d6d4��   �         ZJdS )8�
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                 �   � |j         | _        || _        t          j        || j        �  �        | _        i | _        t          �   �         | _	        d S �N)
�	__class__�class_�manager�weakref�ref�_cleanup�obj�committed_state�set�expired_attributes)�selfr   r   s      �I/opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/orm/state.py�__init__zInstanceState.__init__Y   sA   � ��m�������;�s�D�M�2�2���!���"%�%�%�����    c                 �h   � � t          j        t          � fd�� j        D �   �         �  �        �  �        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   �<