????
Your IP : 18.217.62.185
�
�l�b��>�dZddlZddlmZddlmZddlmZddlmZddlmZdd lm Z dd
lm
Z
ddlmZddlmZdd
lm
Z
ddlmZddlmZddlmZddlmZddlmZejGd�dej����ZGd�de��ZGd�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��eZdZdZdZdZdZejZ e
jZdZ
dZdZdZdZdZdZdZdZdZdZ d�ZdZ ejd���Zed���Zed ���Zed
���Zed���Z ed���Z!ed
���Z"eej#d��d�����Z$d�Z%eej#d��d�����Z&ed���Z'ed���Z(ed���Z)ejd���Z*ejd���Z+ejd���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|_||_tj||j��|_i|_t��|_ dS�N)
� __class__�class_�manager�weakref�ref�_cleanup�obj�committed_state�set�expired_attributes)�selfrrs �g/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib64/python3.11/site-packages/sqlalchemy/orm/state.py�__init__zInstanceState.__init__YsA���m�������;�s�D�M�2�2���!���"%�%�%�����c�h��tjt�fd��jD������S)aaReturn 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.
c3�<�K�|]}|t�|��fV��dSr)�AttributeState)�.0�keyr"s �r#� <genexpr>z&InstanceState.attrs.<locals>.<genexpr>us2�����J�J�c�#�~�d�C�0�0�1�J�J�J�J�J�Jr%)r�ImmutableProperties�dictr�r"s`r#�attrszInstanceState.attrshs<����'��J�J�J�J�T�\�J�J�J�J�J�
�
�
r%c�$�|jduo|jS)z}Return ``True`` if the object is :term:`transient`.
.. seealso::
:ref:`session_object_states`
N�r*� _attachedr.s r#� transientzInstanceState.transientxs���x�4��6���$6�6r%c�"�|jduo|jS)z|Return ``True`` if the object is :term:`pending`.
.. seealso::
:ref:`session_object_states`
Nr1r.s r#�pendingzInstanceState.pending�s���x�4��2�D�N�2r%c�0�|jduo
|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*r2�_deletedr.s r#�deletedzInstanceState.deleted�s��8�x�t�#�H���H�4�=�Hr%c��|jS)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`
)r8r.s r#�was_deletedzInstanceState.was_deleted�s��,�}�r%c�2�|jduo|jo|jS)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`
Nr7r.s r#�
persistentzInstanceState.persistent�s"��&�x�t�#�L���L�t�}�;L�Lr%c�$�|jduo|jS)z|Return ``True`` if the object is :term:`detached`.
.. seealso::
:ref:`session_object_states`
Nr1r.s r#�detachedzInstanceState.detached�s���x�t�#�:�D�N�(:�:r%zsqlalchemy.orm.sessionc�0�|jduo
|j|jvSr)�
session_id� _sessions�r"�
sessionlibs r#r2zInstanceState._attached�s%��
�O�4�'�
8���:�#7�7�
r%c�l�||jvr*t|j��|_t|j|<dSdS)z|Track the last known value of a particular key after expiration
operations.
.. versionadded:: 1.3
N)�_last_known_valuesr-r
�r"r*s r#�_track_last_known_valuez%InstanceState._track_last_known_value�s@���d�-�-�-�&*�4�+B�&C�&C�D�#�+3�D�#�C�(�(�(�.�-r%c�,�|�|��S)aReturn the owning :class:`.Session` for this instance,
or ``None`` if none available.
Note that the result here can in some cases be *different*
from that of ``obj in session``; an object that's been deleted
will report as not ``in session``, however if the transaction is
still in progress, this attribute will still refer to that session.
Only when the transaction is completed does the object become
fully detached under normal circumstances.
)�_state_sessionrCs r#�sessionzInstanceState.session�s���(�(��.�.�.r%c�*�|���S)zMReturn the mapped object represented by this
:class:`.InstanceState`.)rr.s r#�objectzInstanceState.object s���x�x�z�z�r%c�.�|j�dS|jdS)a�Return the mapped identity of the mapped object.
This is the primary key identity as persisted by the ORM
which can always be passed directly to
:meth:`_query.Query.get`.
Returns ``None`` if the object has no primary key identity.
.. note::
An object which is :term:`transient` or :term:`pending`
does **not** have a mapped identity until it is flushed,
even if its attributes include primary key values.
Nr�r*r.s r#�identityzInstanceState.identitys���8���4��8�A�;�r%c��|jS)z�Return the identity key for the mapped object.
This is the key used to locate the object within
the :attr:`.Session.identity_map` mapping. It contains
the identity as returned by :attr:`.identity` within it.
rOr.s r#�identity_keyzInstanceState.identity_key#s���x�r%c��iSrrr.s r#�parentszInstanceState.parents1���� r%c��iSrrr.s r#�_pending_mutationsz InstanceState._pending_mutations5rUr%c��|jjS)z<Return the :class:`_orm.Mapper` used for this mapped object.)r�mapperr.s r#rYzInstanceState.mapper9s���|�"�"r%c�*�t|j��S)z�Return ``True`` if this object has an identity key.
This should always have the same value as the
expression ``state.persistent`` or ``state.detached``.
)�boolr*r.s r#�has_identityzInstanceState.has_identity>s���D�H�~�~�r%c�d�|jjpd}|jjpd}|jjpd}|jjpd}|D]t}|j} |jdu}
|
o| }d|_|r |jr|`|r |r|�|||��n0|�|||��n!| r|�
|||��n|
r|�|||��d|_�udSr) �dispatch�persistent_to_detached�deleted_to_detached�pending_to_transient�persistent_to_transientr8r*rA�_strong_obj)r"�statesrK�to_transientr_r`rarb�stater9r5r=s r#�_detach_stateszInstanceState._detach_statesHs<��
��3�;�t� �&�.�B�J�d��&�/�D�L�����4�<�� �� %� %�E��n�G��i�4�'�G�$��4�W��J�#�E���
�� �
��I��
5��;�.�:�/�/���?�?�?��+�7�*�*�7�E�:�:�:���
5�0�<�#�#�G�U�3�3�3�3��
5�1�=�$�$�W�e�4�4�4� $�E���) %� %r%c�b�|rt�|g|��dSdx|_|_dSr)rrgrArc)r"rKs r#�_detachzInstanceState._detachis=��� 6��(�(�$���9�9�9�9�9�15�5�D�O�d�.�.�.r%c�2�|���|`dSr)rirr.s r#�_disposezInstanceState._disposeos���������H�H�Hr%c��t�dS|���}|�|�|��|`dx|_|_|`dS)z�Weakref callback cleanup.
This callable cleans out the state when it is being garbage
collected.
this _cleanup **assumes** that there are no strong refs to us!
Will not work otherwise!
N)r-�_instance_dict�
_fast_discardrArcr)r"r�
instance_dicts r#rzInstanceState._cleanupssY���<��F��+�+�-�-�
��$��'�'��-�-�-��#�.2�1���$�*��H�H�Hr%c��dSrrr.s r#rzInstanceState.obj�����tr%c�Z�|���}|�tj|��SiS)aReturn the instance dict used by the object.
Under normal circumstances, this is always synonymous
with the ``__dict__`` attribute of the mapped object,
unless an alternative instrumentation system has been
configured.
In the case that the actual object has been garbage
collected, this accessor returns a blank dictionary.
)rrro)r"�os r#r-zInstanceState.dict�s,��
�H�H�J�J���=��%�a�(�(�(��Ir%c�J�|d|d|dd�}}}|j}|j�|||�� |j|dd�i|��S#t j��5|j�|||��ddd��YdS#1swxYwYYdSxYw)Nrrr)rr^�init�
original_initr�safe_reraise�init_failure)�mixed�kwargsr"�instance�argsrs r#�_initialize_instancez"InstanceState._initialize_instance�s��$�Q�x��q��5����9��h���,������d�D�&�1�1�1� B�(�7�(�%����)�>�v�>�>�>�� B��"�$�$�
B�
B�� �-�-�d�D�&�A�A�A�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B����
B�
B�
B�
B�
B�
B�
B���s/�A�B"�)B�B"�B �B"�B �B"c�Z�|j|j�||j|��Sr)r�impl�get_historyr-)r"r*�passives r#r�zInstanceState.get_history�s&���|�C� �%�1�1�$�� �7�K�K�Kr%c�&�|j|jSr)rrrGs r#�get_implzInstanceState.get_impl�s���|�C� �%�%r%c�Z�||jvrt��|j|<|j|Sr)rW�PendingCollectionrGs r#�_get_pending_mutationz#InstanceState._get_pending_mutation�s1���d�-�-�-�+<�+>�+>�D�#�C�(��&�s�+�+r%c���d����i}|��fd�dD�����jr�j���|d<�j��|��|d<|S)Nr{c3�H�K�|]}|�jv�|�j|fV��dSr)�__dict__)r)�kr"s �r#r+z-InstanceState.__getstate__.<locals>.<genexpr>�sL�����
�
���D�M�!�!���
�a� �!�"�!�!�!�
�
r%)rrW�modified�expired� callablesr*rT�load_optionsrr!�info� load_pathr)r�updater�� serializer�
_serialize)r"�
state_dicts` r#�__getstate__zInstanceState.__getstate__�s���� �$�(�(�*�*�-�
����
�
�
�
��
�
�
�
�
�
�"�>� A�&*�n�&>�&>�&@�&@�J�{�#� $�� 7� 7��j� I� I�
�9���r%c����d}|�,tj||j��|_|j|_nd|_�d|_��di��|_��di��|_��di��|_ ��dd��|_
��dd��|_d �vr |j�
�d ��d
�vr��d
|_ �d|_n�#t $r^t#��|_t%|j��D]3}|j||ur"|j�|��|j|=�4Yn)wxYwd�vr�d|_nt#��|_|j�
�fd�d
D����|jrT |jd|_n@#t.$r3t1|j��dksJ�|jdz|_d|_YnwxYwd�vrt3j�d��|_�d||���dS)Nr{rrrWrTr�Fr�r�r�r!c�,��g|]}|�v�|�|f��Srr)r)r�r�s �r#�
<listcomp>z.InstanceState.__setstate__.<locals>.<listcomp>�s3���
�
�
���
�?�?��J�q�M�"�"�?�?r%)r*r�rrr�r)rrrrrr�getrrWrTr�r�r�r�r�r!�KeyErrorr �list�addr�r*�identity_token�
IndexError�lenr�deserializer�)r"r��instr�s ` r#�__setstate__zInstanceState.__setstate__�s�����*�%�����{�4���7�7�D�H��.�D�K�K�
�D�H�$�X�.�D�K�)�~�~�.?��D�D���",�.�.�1E�r�"J�"J���!�~�~�i��4�4���"���z�5�9�9��
�!�~�~�i��7�7����Z����I���Z��/�0�0�0��*�$�$�'��4�D�N�
.�*4�5I�*J��'�'���
.�
.�
.�*-�%�%��'��d�n�-�-�.�.�A��~�a�(�D�0�0��/�3�3�A�6�6�6� �N�1�-��.�.�
.����$�z�1�1�*4�5I�*J��'�'�*-�%�%��'��
���
�
�
�
�0�
�
�
�
�
�
��8� +�
+�&*�h�q�k��#�#���
+�
+�
+��4�8�}�}��)�)�)�)��8�g�-���&*��#�#�#�
+�����*�$�$�)�5�j��6M�N�N�D�N��
�9��d�D�*�5�5�5�5�5s%�
D�A%E?�>E?�G(�(:H%�$H%c�*�|�|d��}|�<|j|jjr%|j|j�|��|j�|��|jr|j�|d��dSdS)zHRemove the given attribute and any
callables associated with it.N)�poprr�
collection�_invalidate_collectionr!�discardr�)r"�dict_r*�olds r#�_resetzInstanceState._resets����i�i��T�"�"���?�t�|�C�0�5�@�?��L���"�9�9�#�>�>�>���'�'��,�,�,��>� *��N���s�D�)�)�)�)�)� *� *r%c�N�d|jvrt|j��|_dSdS�Nr�)r�r-r�)r"�from_s r#�_copy_callableszInstanceState._copy_callabless,���%�.�(�(�!�%�/�2�2�D�N�N�N�)�(r%c�P����|�j��jr���fd�}n��fd�}|S)Nc���d|jvri|_|��d��}|���|���|j�<dSr�)r�r�r�r�)rfr��rowr��fnrr*s ���r#�
_set_callablezGInstanceState._instance_level_callable_processor.<locals>._set_callable&sU����e�n�4�4�&(�E�O��i�i��T�*�*���?��/�/��4�4�4�')����$�$�$r%c�<��d|jvri|_�|j�<dSr�)r�r�)rfr�r�r�r*s ��r#r�zGInstanceState._instance_level_callable_processor.<locals>._set_callable0s)����e�n�4�4�&(�E�O�')����$�$�$r%)rr�)�clsrr�r*r�rs `` @r#�"_instance_level_callable_processorz0InstanceState._instance_level_callable_processor!si������s�|� ���?� *�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
�r%c���d|_|jr5|�|��|j���d|_d|_d|jvr|jd=d|jvr|jd=|j��fd�|j j
D����|jr*|j�|j��D]
}|j|=�|j j
����D]#}��|��}d|j_�$|jr+|j��fd�|jD����|j j����D]}�|=�|j j�|d��dS)NTFrWrTc�>��g|]}|js |j�v�|j��Sr)�expire_missingr*)r)rr�s �r#r�z)InstanceState._expire.<locals>.<listcomp>Hs?���
�
�
���&�
�+/�(�e�*;�*;���*;�*;�*;r%c3�4�K�|]}|�v�|�|fV��dSrr)r)r�r�s �r#r+z(InstanceState._expire.<locals>.<genexpr>Xs8�����+�+�"#�!�u�*�*��E�!�H�
�*�*�*�*�+�+r%)r�r�r�r�clearrcr�r!r�r�_scalar_loader_implsr��intersection�_collection_impl_keysr��_sa_adapter�invalidatedrF�_all_key_setr^�expire)r"r��modified_setr�r�r*s ` r#�_expirezInstanceState._expire7s��������=� "�� � ��&�&�&�� �&�&�(�(�(�!�D�M�����4�=�0�0��
�2�3���
�%�%��
�i�(���&�&�
�
�
�
� �L�=�
�
�
�
�
�
��>� &��,�9�9�$�.�I�I�
&�
&���N�1�%�%���3�@�@��G�G� 6� 6�A����1���J�15�J�"�.�.��"� ��#�*�*�+�+�+�+�'+�'>�+�+�+�
�
�
��<�,�9�9�%�@�@� � �C��c�
�
����$�$�T�4�0�0�0�0�0r%c�T�|j�dd��}|j}|D]�}|j|j}|jr1|r|js||vr�)|j�|��|r||vr||=|� |t��}|jr|tur|�|��|j
r||j
vr|tur
||j
|<|j� |d��|r|� |d����|jj�||��dS)NrW)r�r�r�rr�accepts_scalar_loader� callable_r!r�r�r
r�r�rFrr^r�) r"r��attribute_names� no_loaderr5r�r*rr�s r#�_expire_attributesz InstanceState._expire_attributesas]���-�#�#�$8�$�?�?���N� �"� '� '�C��<��$�)�D��)�
'���$�.��C�9�4D�4D���'�+�+�C�0�0�0��'�� �!1�!1�!�#���)�)�C��*�*�C���
1�3�h�#6�#6��+�+�C�0�0�0��'�
3��4�2�2�2��x�'�'�/2��'��,�� �$�$�S�$�/�/�/��
'����C��&�&�&�����$�$�T�?�;�;�;�;�;r%c���|tzstS|j�|j��}|j�||��|j���tS)z�__call__ allows the InstanceState to act as a deferred
callable for loading expired attributes, which is also
serializable (picklable).
) rrr!r��
unmodifiedr�deferred_scalar_loaderr�r)r"rfr��toloads r#�
_load_expiredzInstanceState._load_expired�sd����� %�$�$��(�5�5�d�o�F�F����+�+�D�&�9�9�9�
��%�%�'�'�'��r%c�Z�t|j���|j��S)z8Return the set of keys which have no uncommitted changes)r r�
differencerr.s r#r�zInstanceState.unmodified�s%���4�<� � �+�+�D�,@�A�A�Ar%c��t|���|j���|j��S)z*Return self.unmodified.intersection(keys).)r r�rr�r)r"�keyss r#�unmodified_intersectionz%InstanceState.unmodified_intersection�s1��
��I�I�
�\�$�,�
'�
'�
�Z��,�
-�
-�
r%c��t|j���|j���|j��S)��Return the set of keys which do not have a loaded value.
This includes expired attributes and any other attribute that
was never populated or modified.
)r rr�rr-r.s r#�unloadedzInstanceState.unloaded�s5��
�����
�Z��,�
-�
-�
�Z�� �
"�
"�
r%c�Z���j��fd��jD����S)r�c3�J�K�|]}�j|jj�|V��dSr)rrr��r)�attrr"s �r#r+z3InstanceState.unloaded_expirable.<locals>.<genexpr>�sJ�����*
�*
���|�D�!�&�5�*
��*
�*
�*
�*
�*
�*
r%�r�r�rr.s`r#�unloaded_expirablez InstanceState.unloaded_expirable�sG����}�)�)�*
�*
�*
�*
���*
�*
�*
�
�
�
r%c�Z���j��fd��jD����S)Nc3�J�K�|]}�j|jj�|V��dSr)rrr�r�s �r#r+z5InstanceState._unloaded_non_object.<locals>.<genexpr>�sJ�����*
�*
���|�D�!�&�<�*
��*
�*
�*
�*
�*
�*
r%r�r.s`r#�_unloaded_non_objectz"InstanceState._unloaded_non_object�sE����}�)�)�*
�*
�*
�*
���*
�*
�*
�
�
�
r%c��dSrrr.s r#rmzInstanceState._instance_dict�rqr%c���|r�|jsdS|r%|j|vrtjd|jz���|j|jvs|rV|rE|t
ur|j|vr
||j}|dtt
fvr|�|��}||j|j<|j|jvrt|j|j<|j r|j
�|js�d|_|���}|r|j
�|��|���}|j r||_
|�A|rAt!jd|j|j�dt'j|���d����dSdSdS)NzHCan't flag attribute '%s' modified; it's not present in the object stateTz'Can't emit change event for attribute 'z' - parent object of type z has been garbage collected.)�send_modified_eventsr*�sa_exc�InvalidRequestErrorrr r
�copyrFrArcr�rm� _modifiedr�r�orm_exc�ObjectDereferencedErrorrr�state_class_str)r"r�r��previousr��is_userlandror�s r#�_modified_eventzInstanceState._modified_event�s���� =��,�
����
�t�x�u�4�4��0�'�)-��2�����x�t�3�3�3�{�3��7��9�,�,��8�u�,�,�',�T�X��H���h� �'B�B�B�#'�9�9�X�#6�#6��19��$�T�X�.��x�4�2�2�2�4<��'���1�
�O� �� 0� 8��� 8� �D�M� �/�/�1�1�M��
2��'�+�+�D�1�1�1�
�8�8�:�:�D���
(�#'�� ��|��|��5�5��|�D�H�-�-�-�t�/C�D�/I�/I�/I�/I�K����!9� 8��|�|�|r%c�d�|D]}|j�|d���d|_|j�t|���|����|jrEt|j���|���|��D]}|j|=�dSdS)a8Commit attributes.
This is used by a partial-attribute load operation to mark committed
those attributes which were refreshed from the database.
Attributes marked as "expired" can potentially remain "expired" after
this step if a value was not populated in state.dict.
NF)rr�r�r!�difference_updater r�r�)r"r�r�r*s r#�_commitzInstanceState._commit�s���� 0� 0�C�� �$�$�S�$�/�/�/�/������1�1���I�I�"�"�5�)�)�
�
�
��>� (��D�N�#�#�0�0��6�6�C�C�E�J�J�
(�
(���N�3�'�'� (� (�
(�
(r%c�8�|�||fg|��dS)aScommit all attributes unconditionally.
This is used after a flush() or a full load/refresh
to remove all pending state from the instance.
- all attributes are marked as "committed"
- the "strong dirty reference" is removed
- the "modified" flag is set to False
- any "expired" markers for scalar attributes loaded are removed.
- lazy load callables for objects / collections *stay*
Attributes marked as "expired" can potentially remain
"expired" after this step if a value was not populated in state.dict.
N)�_commit_all_states)r"r�ros r#�_commit_allzInstanceState._commit_alls&��
���$�����?�?�?�?�?r%c��|D]~\}}|j}|j���d|vr|d=|j�|��|r!|jr|j�|��dx|_|_d|_ �dS)z.Mass / highly inlined version of commit_all().rWFN)
r�rr�r!r�r�r�r�r�rc)r"�iter_rorfr�r�s r#r�z InstanceState._commit_all_states*s���"� %� %�L�E�5���J��!�'�'�)�)�)�#�z�1�1��3�4��$�6�6�u�=�=�=��
7���
7��'�/�/��6�6�6�-2�2�E�N�U�]� $�E��� %� %r%)Fr)FF)K�__name__�
__module__�__qualname__�__doc__rAr*�runidr� EMPTY_SETr�r�rootr��insert_orderrcr�r�r8�
_load_pending�_orphaned_outside_of_session�is_instancer�rFr�r$r!�memoized_propertyr/�propertyr3r5r9r;r=r?�dependenciesr2rHrKrMrPrRrTrWrYr\�classmethodrgrirkrrr-r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rmr�r�r�r�rr%r#rr"s���������2�J�
�C��E��>�L��!�I��L��K��H��G��H��M�#(� ��K��N����I� �(�(�(���<�
��
�
���
��7�7��X�7�� 3� 3��X� 3��I�I��X�I�:����X��.�M�M��X�M�(�;�;��X�;���T��/�0�0�
�
�1�0��X�
�
4�
4�
4���T��/�0�0�/�/�1�0��X�/�����X��
����X��&����X��
�������
�������
��#�#���#�����X���%�%�%��[�%�@6�6�6�6�������<�������X��$
B�
B�
B�L�L�L�&�&�&�,�,�,�
���486�86�86�t *� *� *�3�3�3�����[��*(1�(1�(1�T<�<�<�<�>���,�B�B��X�B�
�
�
��
�
��X�
��
�
��X�
��
�
��X�
����DI�-�-�-�-�^(�(�(�:@�@�@�@�$�%�%�%��[�%�%�%r%rc�`�eZdZdZd�Zed���Zed���Zed���Zd�Z dS)r(a�Provide an inspection interface corresponding
to a particular attribute on a particular mapped object.
The :class:`.AttributeState` object is accessed
via the :attr:`.InstanceState.attrs` collection
of a particular :class:`.InstanceState`::
from sqlalchemy import inspect
insp = inspect(some_mapped_object)
attr_state = insp.attrs.some_attribute
c�"�||_||_dSr)rfr*)r"rfr*s r#r$zAttributeState.__init__Ns����
�����r%c�V�|jj�|jt��S)z�The current value of this attribute as loaded from the database.
If the value has not been loaded, or is otherwise not present
in the object's dictionary, returns NO_VALUE.
)rfr-r�r*r
r.s r#�loaded_valuezAttributeState.loaded_valueRs ���z��"�"�4�8�X�6�6�6r%c��|jj|j�|j���|jj��S)z�Return the value of this attribute.
This operation is equivalent to accessing the object's
attribute directly or via ``getattr()``, and will fire
off any pending loader callables if needed.
)rfrr*�__get__rrr.s r#�valuezAttributeState.value\s>���z�!�$�(�+�3�3��J�N�N���d�j�/�
�
�
r%c�L�|j�|jt��S)aiReturn the current **pre-flush** change history for
this attribute, via the :class:`.History` interface.
This method will **not** emit loader callables if the value of the
attribute is unloaded.
.. note::
The attribute history system tracks changes on a **per flush
basis**. Each time the :class:`.Session` is flushed, the history
of each attribute is reset to empty. The :class:`.Session` by
default autoflushes each time a :class:`_query.Query` is invoked.
For
options on how to control this, see :ref:`session_flushing`.
.. seealso::
:meth:`.AttributeState.load_history` - retrieve history
using loader callables if the value is not locally present.
:func:`.attributes.get_history` - underlying function
)rfr�r*rr.s r#�historyzAttributeState.historyis��4�z�%�%�d�h�0E�F�F�Fr%c�\�|j�|jttz��S)a%Return the current **pre-flush** change history for
this attribute, via the :class:`.History` interface.
This method **will** emit loader callables if the value of the
attribute is unloaded.
.. note::
The attribute history system tracks changes on a **per flush
basis**. Each time the :class:`.Session` is flushed, the history
of each attribute is reset to empty. The :class:`.Session` by
default autoflushes each time a :class:`_query.Query` is invoked.
For
options on how to control this, see :ref:`session_flushing`.
.. seealso::
:attr:`.AttributeState.history`
:func:`.attributes.get_history` - underlying function
.. versionadded:: 0.9.0
)rfr�r*r
rr.s r#�load_historyzAttributeState.load_history�s#��2�z�%�%�d�h��g�0E�F�F�Fr%N)
r�r�r�r�r$rrrr
rrr%r#r(r(?s�������������7�7��X�7��
�
��X�
��G�G��X�G�6G�G�G�G�Gr%r(c�$�eZdZdZd�Zd�Zd�ZdS)r�aA writable placeholder for an unloaded collection.
Stores items appended to and removed from a collection that has not yet
been loaded. When the collection is loaded, the changes stored in
PendingCollection are applied to it to produce the final result.
c�f�tj��|_tj��|_dSr)r�IdentitySet�
deleted_items�OrderedIdentitySet�added_itemsr.s r#r$zPendingCollection.__init__�s*��!�-�/�/����2�4�4����r%c��||jvr|j�|��dS|j�|��dSr)r�removerr��r"rs r#�appendzPendingCollection.append�sJ���D�&�&�&���%�%�e�,�,�,�,�,��� � ��'�'�'�'�'r%c��||jvr|j�|��dS|j�|��dSr)rrrr�rs r#rzPendingCollection.remove�sJ���D�$�$�$���#�#�E�*�*�*�*�*���"�"�5�)�)�)�)�)r%N)r�r�r�r�r$rrrr%r#r�r��sK��������5�5�5�(�(�(�*�*�*�*�*r%r�)r�r�rrr�rrrr r
rrr
r�
path_registryrr�rr�_self_inspects�InspectionAttrInforrMr(r�rr%r#�<module>rs���������������������������������������������������'�'�'�'�'�'�#�#�#�#�#�#�������������'�'�'�'�'�'���������������������Y%�Y%�Y%�Y%�Y%�J�1�Y%�Y%���Y%�x_G�_G�_G�_G�_G�V�_G�_G�_G�D*�*�*�*�*��*�*�*�*�*r%