Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
local
/
lib
/
python3.10
/
dist-packages
/
sqlalchemy
/
orm
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: instrumentation.cpython-310.pyc
o [�h�F � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ e�� Z G d d � d e �ZG dd� de�Z G d d� de�Ze� Zej ZZej ZZej ZZdd� Zdd� Zdd� Zdd� ZdS )a� Defines SQLAlchemy's system of class instrumentation. This module is usually not directly visible to user applications, but defines a large part of the ORM's interactivity. instrumentation.py deals with registration of end-user classes for state tracking. It interacts closely with state.py and attributes.py which establish per-instance and per-class-attribute instrumentation, respectively. The class instrumentation system can be customized on a per-class or global basis using the :mod:`sqlalchemy.ext.instrumentation` module, which provides the means to build and specify alternate instrumentation forms. .. versionchanged: 0.8 The instrumentation extension system was moved out of the ORM and into the external :mod:`sqlalchemy.ext.instrumentation` package. When that package is imported, it installs itself within sqlalchemy.orm so that its more comprehensive resolution mechanics take effect. � )�base)�collections)�exc)� interfaces)�state� )�utilc @ s� e Zd ZdZejZejZe e �e��ZdZ ejZdZdd� Zdd� Zdd� Zed d � �Zedd� �Zed d� �Zedd� �Ze jdd� �ZdZdd�ZdZdd�Zdd� Zdd� Zdd� Z dd� Z!e jdd � �Z"d!d"� Z#d#d$� Z$e j%d%d&� �Z&e j%d'd(� �Z'e j%d)d*� �Z(d[d,d-�Z)d.d/� Z*d0d1� Z+d[d2d3�Z,d4d5� Z-d6d7� Z.d8d9� Z/d:d;� Z0d<d=� Z1d>d?� Z2d@dA� Z3d[dBdC�Z4dDdE� Z5edFdG� �Z6dZdHdI�Z7dZdJdK�Z8dLdM� Z9dNdO� Z:dPdQ� Z;dRdS� Z<d[dTdU�Z=dVdW� Z>e>Z?dXdY� Z@dS )\�ClassManagerz,tracks state information at the class level.Nc C s� || _ i | _d | _i | _i | _dd� dd� | j jD �D �| _| jD ]}| �|� q!| jj � || � |jD ]}t|�}|d urE| j� |j� q4| �� | �� d|jv r\t�d| � d S d S )Nc S s g | ]}|d ur|�qS �N� )�.0�mgrr r �I/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/instrumentation.py� <listcomp>A s �z)ClassManager.__init__.<locals>.<listcomp>c S s g | ]}t |t�rt|��qS r )� isinstance�type�manager_of_class)r r r r r r C s ���__del__z�__del__() method on class %s will cause unreachable cycles and memory leaks, as SQLAlchemy instrumentation often creates reference cycles. Please remove this method.)�class_�info�new_init�local_attrs� originals� __bases__�_bases�update�dispatch�_events�_new_classmanager_instance�__mro__r �_update�manage�_instrument_init�__dict__r �warn)�selfr �base_�baseclsr r r r �__init__: s6 �� � ���zClassManager.__init__c C � t | �S r )�id�r% r r r �__hash__` � zClassManager.__hash__c C s || u S r r )r% �otherr r r �__eq__c r- zClassManager.__eq__c C s d| j v S )N�mapper)r# r+ r r r � is_mappedf s zClassManager.is_mappedc C r) r )� frozensetr+ r r r �_all_key_setj s zClassManager._all_key_setc C � t dd� | �� D ��S )Nc S s g | ] }|j jr|j�qS r )�impl� collection�key�r �attrr r r r q s z6ClassManager._collection_impl_keys.<locals>.<listcomp>�r2 �valuesr+ r r r �_collection_impl_keysn s �z"ClassManager._collection_impl_keysc C r4 )Nc S s g | ] }|j jr|j �qS r )r5 �accepts_scalar_loaderr8 r r r r w s ��z5ClassManager._scalar_loader_impls.<locals>.<listcomp>r: r+ r r r �_scalar_loader_implst s ��z!ClassManager._scalar_loader_implsc C s t �| j��r )r �UnmappedClassErrorr r+ r r r r0 ~ s zClassManager.mapperc c sh � |du rt � }| jjD ]%}t |j��|�D ]}|�|� |j| }t|tj�r0|j r0||fV qqdS )a return an iterator of all classbound attributes that are implement :class:`.InspectionAttr`. This includes :class:`.QueryableAttribute` as well as extension types such as :class:`.hybrid_property` and :class:`.AssociationProxy`. N) �setr r r# � difference�addr r �InspectionAttr�is_attribute)r% �exclude�superclsr7 �valr r r �_all_sqla_attributes� s � �� ���z!ClassManager._all_sqla_attributesc C s* | j jD ]}||jv r|j| S q|S )z5return an attribute on the class without tripping it.)r r r# )r% r7 �defaultrF r r r �_get_class_attr_mro� s �z ClassManager._get_class_attr_mroc C s || v o | | j duS )z\Return True if the given attribute is fully initialized. i.e. has an impl. N�r5 �r% r7 r r r �_attr_has_impl� s zClassManager._attr_has_implc C s t |�}|du r t�|�}|S )a� Create a new ClassManager for a subclass of this ClassManager's class. This is called automatically when attributes are instrumented so that the attributes can be propagated to subclasses against their own class-local manager, without the need for mappers etc. to have already pre-configured managers for the full class hierarchy. Mappers can post-configure the auto-generated ClassManager when needed. N�r �_instrumentation_factory�create_manager_for_cls)r% �cls�managerr r r �_subclass_manager� s zClassManager._subclass_managerc C s* | j j| _t| j | �| _| �d| j� d S �Nr( )r r( � original_init�_generate_initr �install_memberr+ r r r r"