ó
¿b›]c           @   sƒ  d  Z  d d l m Z d d l m Z e e f Z d e j f d „  ƒ  YZ	 e	 Z
 d e j f d „  ƒ  YZ d e j f d	 „  ƒ  YZ d
 e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d „  Z e j d ƒ d „  ƒ Z d S(    s   SQLAlchemy ORM exceptions.i   (   t   exc(   t   utilt   StaleDataErrorc           B   s   e  Z d  Z RS(   sa  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".

    (   t   __name__t
   __module__t   __doc__(    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR      s   t
   FlushErrorc           B   s   e  Z d  Z RS(   s0   A invalid condition was detected during flush().(   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   -   s   t   UnmappedErrorc           B   s   e  Z d  Z RS(   s?   Base for exceptions that involve expected mappings not present.(   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   1   s   t   ObjectDereferencedErrorc           B   s   e  Z d  Z RS(   sP   An operation cannot complete due to an object being garbage
    collected.

    (   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   5   s   t   DetachedInstanceErrorc           B   s   e  Z d  Z d Z RS(   sS   An attempt to access unloaded attributes on a
    mapped instance that is detached.t   bhk3(   R   R   R   t   code(    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR	   <   s   t   UnmappedInstanceErrorc           B   s2   e  Z d  Z e j d ƒ d d „ ƒ Z d „  Z RS(   s;   An mapping operation was requested for an unknown instance.s   sqlalchemy.orm.basec         C   s¢   | sŽ y9 | j  t | ƒ ƒ t t | ƒ ƒ } d | | f } WqŽ t k
 rŠ t t | ƒ ƒ } t | t ƒ r‹ | d t | ƒ 7} q‹ qŽ Xn  t j |  | ƒ d  S(   Ns“   Class %r is mapped, but this instance lacks instrumentation.  This occurs when the instance is created before sqlalchemy.orm.mapper(%s) was called.s;   ; was a class (%s) supplied where an instance was required?(   t   class_mappert   typet   _safe_cls_namet   UnmappedClassErrort   _default_unmappedt
   isinstanceR   t   __init__(   t   selft   baset   objt   msgt   name(    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   F   s    c         C   s   |  j  d  |  j d f f S(   Ni    (   t	   __class__t   Nonet   args(   R   (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyt
   __reduce__[   s    N(   R   R   R   R   t   dependenciesR   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   C   s   R   c           B   s#   e  Z d  Z d d „ Z d „  Z RS(   s8   An mapping operation was requested for an unknown class.c         C   s)   | s t  | ƒ } n  t j |  | ƒ d  S(   N(   R   R   R   (   R   t   clsR   (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   b   s    c         C   s   |  j  d  |  j d f f S(   Ni    (   R   R   R   (   R   (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   g   s    N(   R   R   R   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   _   s   t   ObjectDeletedErrorc           B   s2   e  Z d  Z e j d ƒ d d „ ƒ Z d „  Z RS(   sé  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.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.

    s   sqlalchemy.orm.basec         C   s3   | s d | j  | ƒ } n  t j j |  | ƒ d  S(   NsD   Instance '%s' has been deleted, or its row is otherwise not present.(   t	   state_strt   sa_exct   InvalidRequestErrorR   (   R   R   t   stateR   (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR      s    c         C   s   |  j  d  |  j d f f S(   Ni    (   R   R   R   (   R   (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   ‰   s    N(   R   R   R   R   R   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   k   s   	t   UnmappedColumnErrorc           B   s   e  Z d  Z RS(   s5   Mapping operation was requested on an unknown column.(   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR$      s   t   NoResultFoundc           B   s   e  Z d  Z RS(   s2   A database result was required but none was found.(   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR%   ‘   s   t   MultipleResultsFoundc           B   s   e  Z d  Z RS(   sC   A single database result was required but more than one were found.(   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR&   •   s   t   LoaderStrategyExceptionc           B   s   e  Z d  Z d „  Z RS(   s2   A loader strategy for an attribute does not exist.c         C   sn   | d  k r, t j j |  d | | f ƒ n> t j j |  d t j | ƒ | t j | ƒ t j | ƒ f ƒ d  S(   Ns   Can't find strategy %s for %ssu   Can'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   R   t   clsname_as_plain_name(   R   t   applied_to_property_typet   requesting_propertyt
   applies_tot   actual_strategy_typet   strategy_key(    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   œ   s    		(   R   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR'   ™   s   c         C   sd   y d j  |  j |  j f ƒ } Wn> t k
 r_ t |  d d  ƒ } | d  k r` t |  ƒ } q` n X| S(   Nt   .R   (   t   joinR   R   t   AttributeErrort   getattrR   t   repr(   R   t   cls_name(    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   ¹   s    s   sqlalchemy.orm.basec         C   sd   y |  j  | ƒ j } Wn- t k
 r/ i  } n t k
 rE i  } n Xt | ƒ } | s` d | Sd  S(   Ns   Class '%s' is not mapped(   t   manager_of_classt   mapperst   NO_STATEt	   TypeErrorR   (   R   R   R5   R   (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyR   Ã   s    	
N(   R   t    R    R!   R   R0   t   KeyErrorR6   t   SQLAlchemyErrorR   t   ConcurrentModificationErrorR   R"   R   R   R	   R   R   R   R$   R%   R&   R'   R   R   R   (    (    (    s1   lib/python2.7/site-packages/sqlalchemy/orm/exc.pyt   <module>   s$   " 	
