B
    .²ô`Ø  ã               @   s  d Z ddlmZ ddlmZ eefZG dd„ dejƒZ	e	Z
G dd„ dejƒZG dd	„ d	ejƒZG d
d„ dejƒZG dd„ dejƒZG dd„ deƒZG dd„ deƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZdd„ Ze d¡dd „ ƒZd!S )"zSQLAlchemy ORM exceptions.é   )Úexc)Úutilc               @   s   e Zd ZdZdS )ÚStaleDataErroraa  An operation encountered database state that is unaccounted for.

    Conditions which cause this to happen include:

    * A flush may have attempted to update or delete rows
      and an unexpected number of rows were matched during
      the UPDATE or DELETE statement.   Note that when
      version_id_col is used, rows in UPDATE or DELETE statements
      are also matched against the current known version
      identifier.

    * A mapped object with version_id_col was refreshed,
      and the version number coming back from the database does
      not match that of the object itself.

    * A object is detached from its parent object, however
      the object was previously attached to a different parent
      identity which was garbage collected, and a decision
      cannot be made if the new parent was really the most
      recent "parent".

    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r	   r	   úA/home/dcms/DCMS/lib/python3.7/site-packages/sqlalchemy/orm/exc.pyr      s   r   c               @   s   e Zd ZdZdS )Ú
FlushErrorz0A invalid condition was detected during flush().N)r   r   r   r   r	   r	   r	   r
   r   -   s   r   c               @   s   e Zd ZdZdS )ÚUnmappedErrorz?Base for exceptions that involve expected mappings not present.N)r   r   r   r   r	   r	   r	   r
   r   1   s   r   c               @   s   e Zd ZdZdS )ÚObjectDereferencedErrorzPAn operation cannot complete due to an object being garbage
    collected.

    N)r   r   r   r   r	   r	   r	   r
   r   5   s   r   c               @   s   e Zd ZdZdZdS )ÚDetachedInstanceErrorzSAn attempt to access unloaded attributes on a
    mapped instance that is detached.Zbhk3N)r   r   r   r   Úcoder	   r	   r	   r
   r   <   s   r   c               @   s,   e Zd ZdZe d¡ddd„ƒZdd„ ZdS )	ÚUnmappedInstanceErrorz;An mapping operation was requested for an unknown instance.zsqlalchemy.orm.baseNc             C   sz   |sjy*|  t|ƒ¡ tt|ƒƒ}d||f }W n: tk
rh   tt|ƒƒ}t|tƒrd|dt|ƒ 7 }Y nX t | |¡ d S )Nz“Class %r is mapped, but this instance lacks instrumentation.  This occurs when the instance is created before sqlalchemy.orm.mapper(%s) was called.z;; was a class (%s) supplied where an instance was required?)Zclass_mapperÚtypeÚ_safe_cls_nameÚUnmappedClassErrorÚ_default_unmappedÚ
isinstancer   Ú__init__)ÚselfÚbaseÚobjÚmsgÚnamer	   r	   r
   r   F   s    
zUnmappedInstanceError.__init__c             C   s   | j d | jd ffS )Né    )Ú	__class__Úargs)r   r	   r	   r
   Ú
__reduce__[   s    z UnmappedInstanceError.__reduce__)N)r   r   r   r   r   Údependenciesr   r   r	   r	   r	   r
   r   C   s   r   c               @   s"   e Zd ZdZddd„Zdd„ ZdS )r   z8An mapping operation was requested for an unknown class.Nc             C   s   |st |ƒ}t | |¡ d S )N)r   r   r   )r   Úclsr   r	   r	   r
   r   b   s    zUnmappedClassError.__init__c             C   s   | j d | jd ffS )Nr   )r   r   )r   r	   r	   r
   r   g   s    zUnmappedClassError.__reduce__)N)r   r   r   r   r   r   r	   r	   r	   r
   r   _   s   
r   c               @   s,   e Zd ZdZe d¡ddd„ƒZdd„ ZdS )	ÚObjectDeletedErroraï  A refresh operation failed to retrieve the database
    row corresponding to an object's known primary key identity.

    A refresh operation proceeds when an expired attribute is
    accessed on an object, or when :meth:`_query.Query.get` is
    used to retrieve an object which is, upon retrieval, detected
    as expired.   A SELECT is emitted for the target row
    based on primary key; if no row is returned, this
    exception is raised.

    The true meaning of this exception is simply that
    no row exists for the primary key identifier associated
    with a persistent object.   The row may have been
    deleted, or in some cases the primary key updated
    to a new value, outside of the ORM's management of the target
    object.

    zsqlalchemy.orm.baseNc             C   s$   |sd|  |¡ }tj | |¡ d S )NzDInstance '%s' has been deleted, or its row is otherwise not present.)Z	state_strÚsa_excÚInvalidRequestErrorr   )r   r   Ústater   r	   r	   r
   r      s    zObjectDeletedError.__init__c             C   s   | j d | jd ffS )Nr   )r   r   )r   r	   r	   r
   r   ‰   s    zObjectDeletedError.__reduce__)N)r   r   r   r   r   r    r   r   r	   r	   r	   r
   r"   k   s   	r"   c               @   s   e Zd ZdZdS )ÚUnmappedColumnErrorz5Mapping operation was requested on an unknown column.N)r   r   r   r   r	   r	   r	   r
   r&      s   r&   c               @   s   e Zd ZdZdS )ÚNoResultFoundz2A database result was required but none was found.N)r   r   r   r   r	   r	   r	   r
   r'   ‘   s   r'   c               @   s   e Zd ZdZdS )ÚMultipleResultsFoundzCA single database result was required but more than one were found.N)r   r   r   r   r	   r	   r	   r
   r(   •   s   r(   c               @   s   e Zd ZdZdd„ ZdS )ÚLoaderStrategyExceptionz2A loader strategy for an attribute does not exist.c          
   C   sP   |d kr t j | d||f ¡ n,t j | dt |¡|t |¡t |¡f ¡ d S )NzCan't find strategy %s for %szuCan't apply "%s" strategy to property "%s", which is a "%s"; this loader strategy is intended to be used with a "%s".)r#   r$   r   r   Zclsname_as_plain_name)r   Zapplied_to_property_typeZrequesting_propertyZ
applies_toZactual_strategy_typeZstrategy_keyr	   r	   r
   r   œ   s    z LoaderStrategyException.__init__N)r   r   r   r   r   r	   r	   r	   r
   r)   ™   s   r)   c             C   sL   yd  | j| jf¡}W n0 tk
rF   t| dd ƒ}|d krBt| ƒ}Y nX |S )NÚ.r   )Újoinr   r   ÚAttributeErrorÚgetattrÚrepr)r!   Zcls_namer	   r	   r
   r   ¹   s    r   zsqlalchemy.orm.basec             C   sX   y|   |¡j}W n. tk
r(   i }Y n tk
r>   i }Y nX t|ƒ}|sTd| S d S )NzClass '%s' is not mapped)Zmanager_of_classÚmappersÚNO_STATEÚ	TypeErrorr   )r   r!   r/   r   r	   r	   r
   r   Ã   s    
r   N)r   Ú r   r#   r   r,   ÚKeyErrorr0   ZSQLAlchemyErrorr   ZConcurrentModificationErrorr   r$   r   r   r   r   r   r"   r&   r'   r(   r)   r   r    r   r	   r	   r	   r
   Ú<module>   s$   " 
