Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/sqlalchemy/orm/__pycache__/dependency.cpython-39.pyc
Ðазад
a _�hܵ � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddlm Z dd lmZ d dlmZ d dlm Z d dlmZ G dd � d e�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Zeee ee eiZdS )zRelationship dependencies. � )� attributes)�exc)�sync)� unitofwork)�util)� MANYTOMANY)� MANYTOONE)� ONETOMANY� )�sqlc @ s� e Zd Zdd� Zedd� �Zdd� Zdd� Zd d � Zdd� Z d d� Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� Zdd� Zd%dd�Zd d!� Zd"d#� Zd$S )&�DependencyProcessorc C s� || _ |j| _|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j | _ | jr^t j| _nt j | _| jrvt j| _nt j | _|j| _| j js�t�d| j ��d S )Nz|Can't build a DependencyProcessor for relationship %s. No target attributes to populate between parent and child are present)�prop�cascade�mapper�parent� secondary� direction�post_update�passive_deletes�passive_updates�enable_typechecksr �PASSIVE_NO_INITIALIZE�_passive_delete_flag�PASSIVE_OFF�_passive_update_flag�key�synchronize_pairs�sa_exc� ArgumentError)�selfr � r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/sqlalchemy/orm/dependency.py�__init__ s. ��zDependencyProcessor.__init__c C s t |j |�S �N)�_direction_to_processorr )�clsr r r r! �from_relationship6 s z%DependencyProcessor.from_relationshipc C s | j j�| j��|�S )z�return True if the given object instance has a parent, according to the ``InstrumentedAttribute`` handled by this ``DependencyProcessor``. )r Z class_manager�get_implr � hasparent�r �stater r r! r( : s zDependencyProcessor.hasparentc C s |� | d� dS )z�establish actions and dependencies related to a flush. These actions will operate on all relevant states in the aggregate. TN)�register_preprocessor�r �uowr r r! �per_property_preprocessorsB s z.DependencyProcessor.per_property_preprocessorsc C sz t �|| dd�}t �|| dd�}t �|| jj�}t �|| jj�}t �|| jj�}t �|| jj�}| �|||||||� d S �NFT)r � ProcessAll� SaveUpdateAllr �primary_base_mapperr � DeleteAll�per_property_dependencies)r r- � after_save� before_delete�parent_saves�child_saves�parent_deletes� child_deletesr r r! �per_property_flush_actionsK s. �����z.DependencyProcessor.per_property_flush_actionsc C s� | j j}t�||�}t�||�}|r<t�|| dd�}d|_nt�|| dd�}d|_||jvr�||jvsjJ �|df|dfg} d} nd} |s�t�|| jj �}d }}||jv r�d} n&t�|| jj �}d }}||jv r�d} |D �]}|j | j j� ||j|r�| jntj�}|�sq�|�r8t�|| d|�}| �rZt�||�}n"t�|| d|�}| �rZt�||�}| �r�g } |D ]\\}}||jv�r�d}n6|j| \}}|�r�t�||�df}nt�||�df}| �|� �qh| D ]"\}}| �||||||||� �q�q�dS )z�establish actions and dependencies related to a flush. These actions will operate on all relevant states individually. This occurs only if there are cycles in the 'aggregated' version of events. TFN)NN)r r2 r r1 r3 r0 �disabledZcyclesr �base_mapper�managerr �implZget_all_pending�dictr r r ZProcessStateZDeleteStateZSaveUpdateState�states�append�per_state_dependencies)r r- rA �isdeleteZchild_base_mapperr8 r: r6 r5 Z child_actionsZchild_in_cyclesr7 r9 Zparent_in_cyclesr* Zsum_Zchild_state�child�child_action�deletedZlistonly� childisdeleter r r! �per_state_flush_actionsg s� � �� � ��z+DependencyProcessor.per_state_flush_actionsc C s dS �NFr �r � uowcommitrA r r r! �presort_deletes� s z#DependencyProcessor.presort_deletesc C s dS rJ r rK r r r! � presort_saves� s z!DependencyProcessor.presort_savesc C s d S r# r rK r r r! �process_deletes� s z#DependencyProcessor.process_deletesc C s d S r# r rK r r r! � process_saves� s z!DependencyProcessor.process_savesc C sp |r | j rtj}n| jtu r$tj}ntj}|D ]&}|�|| j|�}|r.|� � s. dS q.|on| j j on| j|j v S )NT)r r r r r ZPASSIVE_NO_FETCH_RELATEDr �get_attribute_historyr �emptyr Z_is_self_referentialr Zmappers)r rL rA rD �passive�s�historyr r r! �prop_has_changes� s � �z$DependencyProcessor.prop_has_changesc C s� | j jr$|d u r$t�d| j f ��nn|d ur�| jj|| j d�s�| jj|dd�rtt�d|j| j | jj| jd� ��nt�d|j| j | jjd� ��d S )Nz-Can't flush None value found in collection %s)Zallow_subtypesTaE Attempting to flush an item of type %(x)s as a member of collection "%(y)s". Expected an object of type %(z)s or a polymorphic subclass of this type. If %(x)s is a subclass of %(z)s, configure mapper "%(zm)s" to load this subtype polymorphically, or set enable_typechecks=False to allow any subtype to be accepted for flush. )�x�y�zZzmz�Attempting to flush an item of type %(x)s as a member of collection "%(y)s". Expected an object of type %(z)s or a polymorphic subclass of this type.)rW rX rY )r �uselistr Z FlushErrorr Z_canloadr �class_r) r r r! �_verify_canload� s6 ��� ������z#DependencyProcessor._verify_canloadc C s t � �d S r# ��NotImplementedError)r r* rE �associationrow� clearkeysrL r r r! �_synchronize" s z DependencyProcessor._synchronizec C s>