관리-도구
편집 파일: deprecated_interfaces.cpython-37.pyc
B ��4]Q � @ s| d dl mZ ddlmZ ddlmZ ej�d�G dd� de��Zej�d�G dd � d e��Z ej�d�G d d� de��Z dS ) � )�EXT_CONTINUE� )�event)�utilzsqlalchemy.orm.interfacesc @ s� e Zd ZdZedd� �Zedd� �Zedd� �Zdd � Zd d� Z dd � Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� Zdd� ZdS )�MapperExtensionaa Base implementation for :class:`.Mapper` event hooks. .. deprecated:: 0.7 :class:`.MapperExtension` is deprecated and will be removed in a future release. Please refer to :func:`.event.listen` in conjunction with the :class:`.MapperEvents` listener interface. New extension classes subclass :class:`.MapperExtension` and are specified using the ``extension`` mapper() argument, which is a single :class:`.MapperExtension` or a list of such:: from sqlalchemy.orm.interfaces import MapperExtension class MyExtension(MapperExtension): def before_insert(self, mapper, connection, instance): print "instance %s before insert !" % instance m = mapper(User, users_table, extension=MyExtension()) A single mapper can maintain a chain of ``MapperExtension`` objects. When a particular mapping event occurs, the corresponding method on each ``MapperExtension`` is invoked serially, and each method has the ability to halt the chain from proceeding further:: m = mapper(User, users_table, extension=[ext1, ext2, ext3]) Each ``MapperExtension`` method returns the symbol EXT_CONTINUE by default. This symbol generally means "move to the next ``MapperExtension`` for processing". For methods that return objects like translated rows or new object instances, EXT_CONTINUE means the result of the method should be ignored. In some cases it's required for a default mapper activity to be performed, such as adding a new instance to a result list. The symbol EXT_STOP has significance within a chain of ``MapperExtension`` objects that the chain will be stopped when this symbol is returned. Like EXT_CONTINUE, it also has additional significance in some cases that a default mapper activity will not be performed. c C s | � ||d� d S )N)�instrument_class)�_adapt_listener_methods)�cls�self�listener� r �W/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/orm/deprecated_interfaces.py�_adapt_instrument_class<