관리-도구
편집 파일: dependency.cpython-38.pyc
U -?�f� � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd l mZ dd l mZ ddl m Z ddlmZ dd lmZ ddlmZ G dd� d�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Ze eeeeeiZdS )zRelationship dependencies. � )�annotations� )� 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 | _d| jj|jf | _|j| _| j js�t�d| j ��d S )Nz%s_%sz|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� _sort_key�key�sort_key�synchronize_pairs�sa_exc� ArgumentError)�selfr � r$ �I/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/orm/dependency.py�__init__ s0 ��zDependencyProcessor.__init__c C s t |j |�S �N)�_direction_to_processorr )�clsr r$ r$ r% �from_relationship; 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_preprocessorsG 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# r1 � after_save� before_delete�parent_saves�child_saves�parent_deletes� child_deletesr$ r$ r% �per_property_flush_actionsP s6 � � � ��z.DependencyProcessor.per_property_flush_actionsc C s� | j j}t�||�}t�||�}|r<t�|| dd�}d|_nt�|| dd�}d|_||jkr�||jksjt�|df|dfg} d} nd} |s�t�|| j j �}d }}||jkr�d} n&t�|| j j �}d }}||jkr�d} |D �]}|j| j j �||j|r�| jntj�}|�sq�|�r8t�|| d|�}| �rZt�||�}n"t�|| d|�}| �rZt�||�}| �r�g } |D ]\\}}||jk�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 r6 r r5 r7 r4 �disabledZcycles�AssertionErrorr �base_mapper�managerr �implZget_all_pending�dictr r r ZProcessStateZDeleteStateZSaveUpdateState�states�append�per_state_dependencies)r# r1 rF �isdeleteZchild_base_mapperr<