ó
H`¾Tc           @   sÏ  d  Z  d d l m Z m Z m Z d d l m Z d d l m Z d d l Z e j	 d d	 ƒ Z
 e j	 d
 d ƒ Z e j	 d d ƒ Z e j	 d d ƒ Z e j	 d d ƒ Z e j	 d d d d ƒZ e j	 d d d d ƒZ e j	 d d d d ƒZ e j	 d d d d ƒZ e j	 d d d d ƒZ e j	 d  d! d d" ƒZ e j	 d# d$ d d% ƒZ e j	 d& d' d d( ƒZ e j	 d) d* d e e Be Be Be BƒZ e j	 d+ d, d e e AƒZ e j	 d- d. d e e AƒZ e j	 d/ d0 d e e AƒZ e j	 d1 d2 d e e AƒZ e j	 d3 d4 d e e AƒZ d5 Z d6 Z d\ Z e j	 d9 ƒ Z  e j	 d: ƒ Z! e j	 d; d< ƒ Z" e j	 d= d> ƒ Z# e j	 d? d@ ƒ Z$ e j	 dA dB ƒ Z% e& d g ƒ Z( dC „  Z) dD „  Z* e j+ e ƒ Z, e j+ dE ƒ Z- dF „  Z. dG „  Z/ dH „  Z0 dI „  Z1 dJ „  Z2 dK „  Z3 dL „  Z4 e j5 e6 ƒ dM „  ƒ Z7 dN „  Z8 dO „  Z9 dP „  Z: dQ „  Z; dR „  Z< dS „  Z= dT „  Z> e j? dU ƒ Z@ e j5 eA ƒ eB dV „ ƒ ZC eD dW „ ZE dX e6 f dY „  ƒ  YZF dZ e6 f d[ „  ƒ  YZG d S(]   s=   Constants and rudimental functions used throughout the ORM.

i   (   t   utilt
   inspectiont   exc(   t
   expressioni   (   R   iÿÿÿÿNt   PASSIVE_NO_RESULTs¦   Symbol returned by a loader callable or other attribute/history
    retrieval operation when a value could not be determined, based
    on loader callable flags.
    t   ATTR_WAS_SETs•   Symbol returned by a loader callable to indicate the
    retrieved value, or values, were assigned to their attributes
    on the target object.
    t
   ATTR_EMPTYs@   Symbol used internally to indicate an attribute had no callable.t   NO_VALUEsÂ   Symbol which may be placed as the 'previous' value of an attribute,
    indicating no value was loaded for an attribute when it was modified,
    and flags indicated we were not to load it.
    t	   NEVER_SETsŽ   Symbol which may be placed as the 'previous' value of an attribute
    indicating that the attribute had not been assigned to previously.
    t	   NO_CHANGEs]   No callables or SQL should be emitted on attribute access
    and no state should change
    t	   canonicali    t   CALLABLES_OKsE   Loader callables can be fired off if a value
    is not present.
    t   SQL_OKsB   Loader callables can emit SQL at least on scalar value attributes.t   RELATED_OBJECT_OKsZ   Callables can use SQL to load related objects as well
    as scalar value attributes.
    i   t   INIT_OKs‹   Attributes should be initialized with a blank
    value (None or an empty collection) upon get, if no other
    value can be obtained.
    i   t   NON_PERSISTENT_OKs9   Callables can be emitted if the parent is not persistent.i   t   LOAD_AGAINST_COMMITTEDsU   Callables should use committed values as primary/foreign keys during a
    load.
    i    t   NO_AUTOFLUSHs*   Loader callables should disable autoflush.i@   t   PASSIVE_OFFs&   Callables can be emitted in all cases.t   PASSIVE_RETURN_NEVER_SETs   PASSIVE_OFF ^ INIT_OKt   PASSIVE_NO_INITIALIZEs'   PASSIVE_RETURN_NEVER_SET ^ CALLABLES_OKt   PASSIVE_NO_FETCHs   PASSIVE_OFF ^ SQL_OKt   PASSIVE_NO_FETCH_RELATEDs   PASSIVE_OFF ^ RELATED_OBJECT_OKt   PASSIVE_ONLY_PERSISTENTs   PASSIVE_OFF ^ NON_PERSISTENT_OKt   _sa_class_managert   _sa_instance_statet   mappert   instrumentort   EXT_CONTINUEt   EXT_STOPt	   ONETOMANYs¢   Indicates the one-to-many direction for a :func:`.relationship`.

This symbol is typically used by the internals but may be exposed within
certain API features.

t	   MANYTOONEs¢   Indicates the many-to-one direction for a :func:`.relationship`.

This symbol is typically used by the internals but may be exposed within
certain API features.

t
   MANYTOMANYs£   Indicates the many-to-many direction for a :func:`.relationship`.

This symbol is typically used by the internals but may be exposed within
certain API features.

t   NOT_EXTENSIONs¡   Symbol indicating an :class:`_InspectionAttr` that's
   not part of sqlalchemy.ext.

   Is assigned to the :attr:`._InspectionAttr.extension_type`
   attibute.

c             s   t  j ‡  f d †  ƒ } | S(   s1   Mark a method as generative, e.g. method-chained.c            sI   | d j  ƒ  } x ˆ  D] } | | |  j ƒ q W|  | | d | Ž | S(   Ni    i   (   t   _clonet   __name__(   t   fnt   argst   kwt   selft	   assertion(   t
   assertions(    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   generateº   s
    (   R    t	   decorator(   R)   R*   (    (   R)   sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   _generative·   s    c         C   s   |  j  j t d  ƒ S(   N(   t   __dict__t   gett   DEFAULT_MANAGER_ATTRt   None(   t   cls(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   manager_of_classÆ   s    R-   c         C   s   t  t |  ƒ ƒ S(   s'   Return a string describing an instance.(   t	   state_strt   instance_state(   t   instance(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   instance_strÎ   s    c         C   s4   |  d k r d Sd |  j j t |  j ƒ  ƒ f Sd S(   s=   Return a string describing an instance via its InstanceState.R0   s   <%s at 0x%x>N(   R0   t   class_R#   t   idt   obj(   t   state(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyR3   Ô   s    c         C   s%   |  d k r d Sd |  j j f Sd S(   sN   Return a string describing an instance's class via its
    InstanceState.
    R0   s   <%s>N(   R0   R7   R#   (   R:   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   state_class_strÝ   s    c         C   s   t  |  ƒ d | S(   Nt   .(   R6   (   R5   t	   attribute(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   attribute_strè   s    c         C   s   t  |  ƒ d | S(   NR<   (   R3   (   R:   R=   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   state_attribute_strì   s    c         C   s   t  |  ƒ j S(   s¥  Given an object, return the primary Mapper associated with the object
    instance.

    Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError`
    if no mapping is configured.

    This function is available via the inspection system as::

        inspect(instance).mapper

    Using the inspection system will raise
    :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is
    not part of a mapping.

    (   t   object_stateR   (   R5   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   object_mapperð   s    c         C   s2   t  |  ƒ } | d k r* t j |  ƒ ‚ n | Sd S(   sµ  Given an object, return the :class:`.InstanceState`
    associated with the object.

    Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError`
    if no mapping is configured.

    Equivalent functionality is available via the :func:`.inspect`
    function as::

        inspect(instance)

    Using the inspection system will raise
    :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is
    not part of a mapping.

    N(   t   _inspect_mapped_objectR0   R   t   UnmappedInstanceError(   R5   R:   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyR@     s    c         C   s>   y t  |  ƒ SWn) t j k
 r% d  St j k
 r9 d  SXd  S(   N(   R4   R   t   UnmappedClassErrorR0   t   NO_STATE(   R5   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyRB     s    c         C   s8   t  j |  t ƒ } | d  k	 r% | j St j |  ƒ ‚ d  S(   N(   R   t   inspectt   FalseR0   R   R   RD   (   t   class_or_mappert   insp(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   _class_to_mapper'  s    c         C   s-   t  j |  t ƒ } | d k	 r% | j Sd Sd S(   s\   Return the :class:`.Mapper` for the given class or None if the
    class is not mapped.
    N(   R   RF   RG   R0   R   (   t   entityRI   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   _mapper_or_none/  s    c         C   s=   t  j |  t ƒ } | d k	 o< t | d ƒ o< | j p< | j S(   sh   Return True if the given object is a mapped class,
    :class:`.Mapper`, or :class:`.AliasedClass`.
    R   N(   R   RF   RG   R0   t   hasattrt	   is_mappert   is_aliased_class(   RK   RI   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   _is_mapped_class;  s
    	c         C   s'   t  |  d ƒ r |  j St j |  ƒ Sd  S(   Nt   key(   RM   RQ   R   t   _column_as_key(   t   attr(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   _attr_as_keyI  s    c         C   sI   t  j |  t ƒ } t | d ƒ r> g  | j j D] } | ^ q. S|  g Sd  S(   Nt
   selectable(   R   RF   RG   RM   RU   t   c(   RK   RI   RV   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   _orm_columnsP  s    c         C   s.   t  j |  t ƒ } | d  k	 o- t | d t ƒ S(   NRO   (   R   RF   RG   R0   t   getattr(   RK   RI   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   _is_aliased_classX  s    c         C   s¯   t  j |  ƒ } | j r* |  } | j }  nC | j rE | j }  |  } n( t | d ƒ rg | j j } }  n |  } y t	 |  | ƒ SWn* t
 k
 rª t j d | | f ƒ ‚ n Xd S(   sŽ   Return a class attribute given an entity and string name.

    May return :class:`.InstrumentedAttribute` or user-defined
    attribute.

    R   s    Entity '%s' has no property '%s'N(   R   RF   t   is_selectableRV   RO   RK   RM   R   R7   RX   t   AttributeErrort   sa_exct   InvalidRequestError(   RK   RQ   RI   t   description(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   _entity_descriptor^  s     				s   manager.mapperc         C   sb   y& t  |  ƒ } | j s d  S| j } Wn t j k
 r= d  SX| rZ | j rZ | j ƒ  n  | Sd  S(   N(   R2   t	   is_mappedR0   R   R   RE   t   _new_mapperst   _configure_all(   R7   t	   configuret   class_managerR   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   _inspect_mapped_class|  s    	c         C   s`   t  |  d | ƒ} | d k rX t |  t ƒ sF t j d |  f ƒ ‚ n  t j |  ƒ ‚ n | Sd S(   sâ  Given a class, return the primary :class:`.Mapper` associated
    with the key.

    Raises :exc:`.UnmappedClassError` if no mapping is configured
    on the given class, or :exc:`.ArgumentError` if a non-class
    object is passed.

    Equivalent functionality is available via the :func:`.inspect`
    function as::

        inspect(some_mapped_class)

    Using the inspection system will raise
    :class:`sqlalchemy.exc.NoInspectionAvailable` if the class is not mapped.

    Rc   s    Class object expected, got '%r'.N(   Re   R0   t
   isinstancet   typeR\   t   ArgumentErrorR   RD   (   R7   Rc   R   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   class_mapper‹  s    t   _InspectionAttrc           B   s>   e  Z d  Z e Z e Z e Z e Z e Z e Z	 e Z
 e Z RS(   s   A base class applied to all ORM objects that can be returned
    by the :func:`.inspect` function.

    The attributes defined here allow the usage of simple boolean
    checks to test basic facts about the object returned.

    While the boolean checks here are basically the same as using
    the Python isinstance() function, the flags here can be used without
    the need to import all of these classes, and also such that
    the SQLAlchemy class system can change while leaving the flags
    here intact for forwards-compatibility.

    (   R#   t
   __module__t   __doc__RG   RZ   RO   t   is_instanceRN   t   is_propertyt   is_attributet   is_clause_elementR!   t   extension_type(    (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyRj   ¦  s   t   _MappedAttributec           B   s   e  Z d  Z RS(   sV   Mixin for attributes which should be replaced by mapper-assigned
    attributes.

    (   R#   Rk   Rl   (    (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyRr   è  s   (   s   mapperR   (H   Rl   t    R    R   R   R\   t   sqlR   t   operatort   symbolR   R   R   R   R   R	   R   R   R   R   R   R   R   R   R   R   R   R   R   R/   t   DEFAULT_STATE_ATTRt   _INSTRUMENTORR   R   R   R   R    R!   t	   frozensetR0   t	   _none_setR,   R2   t
   attrgetterR4   t   instance_dictR6   R3   R;   R>   R?   RA   R@   t	   _inspectst   objectRB   RJ   RL   RP   RT   RW   RY   R_   t   dottedgettert   _state_mapperRg   RG   Re   t   TrueRi   Rj   Rr   (    (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/base.pyt   <module>
   sÚ   																																	B