
H`Tc           @   s  d  Z  d d l Z d d l m Z m Z m Z d d l m Z m Z m Z	 d d l
 m Z m Z m Z d d l
 m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m  Z  d d	 l
 m! Z! m" Z" e j# d
 e j$ e j% e j& f d     Y Z' d e' f d     YZ( d   Z) e j* d  Z+ e j* d  Z, e j* d  Z- d e. f d     YZ/ d e. f d     YZ0 d e0 f d     YZ1 d e1 f d     YZ2 d e0 f d     YZ3 d   Z4 e j* d  Z5 e6 e7 e  e7 e  e7 e  g  Z8 e j9 d d d  d! g  Z: d e: f d"     YZ: e: e; e; e;  Z< e d#  Z= e d$  Z> e? d%  Z@ d&   ZA e? e; e? e; e; d'  ZB e; e; e; d(  ZC d)   ZD d*   ZE d+   ZF d,   ZG d-   ZH d.   ZI d/   ZJ d0   ZK d S(1   s   Defines instrumentation for class attributes and their interaction
with instances.

This module is usually not directly visible to user applications, but
defines a large part of the ORM's interactivity.


iNi   (   t   utilt   eventt
   inspectioni   (   t
   interfacest   collectionst   exc(   t   instance_statet   instance_dictt   manager_of_class(   t   PASSIVE_NO_RESULTt   ATTR_WAS_SETt
   ATTR_EMPTYt   NO_VALUEt	   NEVER_SETt	   NO_CHANGEt   CALLABLES_OKt   SQL_OKt   RELATED_OBJECT_OKt   INIT_OKt   NON_PERSISTENT_OKt   LOAD_AGAINST_COMMITTEDt   PASSIVE_OFFt   PASSIVE_RETURN_NEVER_SETt   PASSIVE_NO_INITIALIZEt   PASSIVE_NO_FETCHt   PASSIVE_NO_FETCH_RELATEDt   PASSIVE_ONLY_PERSISTENTt   NO_AUTOFLUSH(   t	   state_strt   instance_strt   QueryableAttributec           B   s   e  Z d  Z e Z d d d d d  Z e j d    Z	 e
 d  Z d   Z e j d    Z e j d    Z e d    Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z e j d    Z RS(   s  Base class for :term:`descriptor` objects that intercept
    attribute events on behalf of a :class:`.MapperProperty`
    object.  The actual :class:`.MapperProperty` is accessible
    via the :attr:`.QueryableAttribute.property`
    attribute.


    .. seealso::

        :class:`.InstrumentedAttribute`

        :class:`.MapperProperty`

        :attr:`.Mapper.all_orm_descriptors`

        :attr:`.Mapper.attrs`
    c   	      C   s   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ t |  } | r x: | j D], } | | k rR |  j j	 | | j  qR qR Wn  d  S(   N(
   t   class_t   keyt   implt
   comparatort   _parententityt   _of_typeR   t   _basest   dispatcht   _update(	   t   selfR   R    R!   R"   t   parententityt   of_typet   managert   base(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   __init__8   s    						c         C   s
   |  j  j S(   N(   R!   t   supports_population(   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   _supports_populationK   s    c         C   s"   |  j  j t |  t |  |  S(   N(   R!   t   get_historyR   R   (   R(   t   instancet   passive(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR0   O   s    c         C   s   |  S(   N(    (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   __selectable__S   s    c         C   s
   |  j  j S(   s  Return the 'info' dictionary for the underlying SQL element.

        The behavior here is as follows:

        * If the attribute is a column-mapped property, i.e.
          :class:`.ColumnProperty`, which is mapped directly
          to a schema-level :class:`.Column` object, this attribute
          will return the :attr:`.SchemaItem.info` dictionary associated
          with the core-level :class:`.Column` object.

        * If the attribute is a :class:`.ColumnProperty` but is mapped to
          any other kind of SQL expression other than a :class:`.Column`,
          the attribute will refer to the :attr:`.MapperProperty.info`
          dictionary associated directly with the :class:`.ColumnProperty`,
          assuming the SQL expression itself does not have its own ``.info``
          attribute (which should be the case, unless a user-defined SQL
          construct has defined one).

        * If the attribute refers to any other kind of
          :class:`.MapperProperty`, including :class:`.RelationshipProperty`,
          the attribute will refer to the :attr:`.MapperProperty.info`
          dictionary associated with that :class:`.MapperProperty`.

        * To access the :attr:`.MapperProperty.info` dictionary of the
          :class:`.MapperProperty` unconditionally, including for a
          :class:`.ColumnProperty` that's associated directly with a
          :class:`.schema.Column`, the attribute can be referred to using
          :attr:`.QueryableAttribute.property` attribute, as
          ``MyClass.someattribute.property.info``.

        .. versionadded:: 0.8.0

        .. seealso::

            :attr:`.SchemaItem.info`

            :attr:`.MapperProperty.info`

        (   R"   t   info(   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR4   W   s    )c         C   s   t  j |  j  S(   s  Return an inspection instance representing the parent.

        This will be either an instance of :class:`.Mapper`
        or :class:`.AliasedInsp`, depending upon the nature
        of the parent entity which this attribute is associated
        with.

        (   R   t   inspectR#   (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   parent   s    
c         C   s   |  j  j   S(   N(   R"   t   __clause_element__(   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt
   expression   s    c         C   s   |  j  j   S(   N(   R"   R7   (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR7      s    c         C   s   |  j  j   S(   sh   like __clause_element__(), but called specifically
        by :class:`.Query` to allow special behavior.(   R"   t   _query_clause_element(   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR9      s    c      	   C   sG   |  j  s t  |  j | j |  j d |  j d |  j j |  d | S(   NR!   R"   R)   (   R$   t   AssertionErrort	   __class__t   entityR    R!   R"   t   adapt_to_entity(   R(   R=   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR=      s    		c         C   s4   t  |  j |  j |  j |  j j |  |  j d | S(   NR*   (   R   R   R    R!   R"   R*   R#   (   R(   t   cls(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR*      s    	c         C   s   |  j    j |  S(   N(   R9   t   label(   R(   t   name(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR?      s    c         O   s   | |  j  | |  S(   N(   R"   (   R(   t   opt   othert   kwargs(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   operate   s    c         K   s   | | |  j  |  S(   N(   R"   (   R(   RA   RB   RC   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   reverse_operate   s    c         C   s   |  j  j | d | t k	 S(   Nt
   optimistic(   R!   t	   hasparentt   False(   R(   t   stateRF   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRG      s    c         C   s]   y t  |  j |  SWnB t k
 rX t d t |   j t |  j  j |  | f   n Xd  S(   NsF   Neither %r object nor %r object associated with %s has an attribute %r(   t   getattrR"   t   AttributeErrort   typet   __name__(   R(   R    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   __getattr__   s    c         C   s   d |  j  j |  j f S(   Ns   %s.%s(   R   RM   R    (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   __str__   s    c         C   s
   |  j  j S(   s   Return the :class:`.MapperProperty` associated with this
        :class:`.QueryableAttribute`.


        Return values here will commonly be instances of
        :class:`.ColumnProperty` or :class:`.RelationshipProperty`.


        (   R"   t   property(   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRP      s    N(   RM   t
   __module__t   __doc__t   Truet   is_attributet   NoneR-   R    t   memoized_propertyR/   R   R0   R3   R4   R6   RP   R8   R7   R9   R=   R*   R?   RD   RE   RH   RG   RN   RO   (    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR      s,   	+										t   InstrumentedAttributec           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   Class bound instrumented attribute which adds basic
    :term:`descriptor` methods.

    See :class:`.QueryableAttribute` for a description of most features.


    c         C   s)   |  j  j t |  t |  | d   d  S(   N(   R!   t   setR   R   RU   (   R(   R1   t   value(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   __set__   s    c         C   s#   |  j  j t |  t |   d  S(   N(   R!   t   deleteR   R   (   R(   R1   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt
   __delete__   s    c         C   s\   | d  k r |  St |  } |  j r? |  j | k r? | |  j S|  j j t |  |  Sd  S(   N(   RU   R   R/   R    R!   t   getR   (   R(   R1   t   ownert   dict_(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   __get__   s    (   RM   RQ   RR   RZ   R\   R`   (    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRW      s   		c            sX   d t  f   f d     Y} t    j d | _ t j | t    d d d   | S(   s   Create an QueryableAttribute / user descriptor hybrid.

    Returns a new QueryableAttribute type that delegates descriptor
    behavior and getattr() to the given descriptor.
    t   Proxyc              sk   e  Z d  Z d d d d  Z e d    Z e j d    Z d   Z	 d   Z
 d   Z   f d   Z RS(	   s   Presents the :class:`.QueryableAttribute` interface as a
        proxy on top of a Python descriptor / :class:`.PropComparator`
        combination.

        c         S   sC   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   R   R    t
   descriptort   original_propertyt   _comparatort   _adapt_to_entityRR   (   R(   R   R    Rb   R"   R=   t   docRc   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR-     s    						c         S   s
   |  j  j S(   N(   R"   RP   (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRP     s    c         S   sO   t  j |  j  r$ |  j   |  _ n  |  j rH |  j j |  j  |  _ n  |  j S(   N(   R    t   callableRd   Re   R=   (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR"     s    		c         S   s%   |  j  | j |  j |  j |  j |  S(   N(   R;   R<   R    Rb   Rd   (   R(   R=   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR=     s
    c         S   s'   | d  k r |  S|  j j | |  Sd  S(   N(   RU   Rb   R`   (   R(   R1   R^   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR`   $  s    c         S   s   d |  j  j |  j f S(   Ns   %s.%s(   R   RM   R    (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRO   *  s    c            s   y t    |  SWnj t k
 r} y t  |  j |  SWq~ t k
 ry t d t    j t |  j  j |  | f   q~ Xn Xd S(   sN   Delegate __getattr__ to the original descriptor and/or
            comparator.sF   Neither %r object nor %r object associated with %s has an attribute %rN(   RJ   RK   R"   RL   RM   (   R(   t	   attribute(   Rb   (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRN   -  s    N(   RM   RQ   RR   RU   R-   RP   R    RV   R"   R=   R`   RO   RN   (    (   Rb   (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRa      s   					R@   Rb   t   from_instance(   R   RL   RM   R    t   monkeypatch_proxied_specials(   Rb   Ra   (    (   Rb   s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   create_proxied_attribute   s    
Dt   REMOVEt   APPENDt   REPLACEt   Eventc           B   s;   e  Z d  Z d Z d Z d   Z e d    Z d   Z	 RS(   s  A token propagated throughout the course of a chain of attribute
    events.

    Serves as an indicator of the source of the event and also provides
    a means of controlling propagation across a chain of attribute
    operations.

    The :class:`.Event` object is sent as the ``initiator`` argument
    when dealing with the :meth:`.AttributeEvents.append`,
    :meth:`.AttributeEvents.set`,
    and :meth:`.AttributeEvents.remove` events.

    The :class:`.Event` object is currently interpreted by the backref
    event handlers, and is used to control the propagation of operations
    across two mutually-dependent attributes.

    .. versionadded:: 0.9.0

    c         C   s%   | |  _  | |  _ |  j  j |  _ d  S(   N(   R!   RA   t   parent_token(   R(   t   attribute_implRA   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR-   l  s    		c         C   s
   |  j  j S(   N(   R!   R    (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR    q  s    c         C   s   |  j  j |  S(   N(   R!   RG   (   R(   RI   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRG   u  s    N(
   RM   RQ   RR   RU   R!   RA   R-   RP   R    RG   (    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRo   L  s   	t   AttributeImplc           B   s   e  Z d  Z e d d e d e e d  Z d   Z d   Z d   Z	 e
 e e	  Z e d  Z d   Z d   Z e d  Z e d	  Z d
   Z e d  Z e d  Z e d  Z e d  Z e d e d  Z e d  Z d   Z RS(   s4   internal implementation for instrumented attributes.c         K   s   | |  _  | |  _ | |  _ | |  _ | |  _ |	 p6 |  |  _ | |  _ | d k r` t j	 |  _
 n	 | |  _
 t |  | } x- t j | p g   D] } | j | |  q W| r t |  j _ n  |
 |  _ d S(   s  Construct an AttributeImpl.

        \class_
          associated class

        key
          string name of the attribute

        \callable_
          optional function which generates a callable based on a parent
          instance, which produces the "default" values for a scalar or
          collection attribute when it's first accessed, if not present
          already.

        trackparent
          if True, attempt to track if an instance has a parent attached
          to it via this attribute.

        extension
          a single or list of AttributeExtension object(s) which will
          receive set/delete/append/remove/etc. events.  Deprecated.
          The event package is now used.

        compare_function
          a function that compares two values which are normally
          assignable to this attribute.

        active_history
          indicates that get_history() should always return the "old" value,
          even if it means executing a lazy callable upon attribute change.

        parent_token
          Usually references the MapperProperty, used as a key for
          the hasparent() function to identify an "owning" attribute.
          Allows multiple AttributeImpls to all match a single
          owner attribute.

        expire_missing
          if False, don't add an "expiry" callable to this attribute
          during state.expire_attributes(None), if no value is present
          for this key.

        send_modified_events
          if False, the InstanceState._modified_event method will have no
          effect; this means the attribute will never show up as changed in a
          history entry.
        N(   R   R    t	   callable_R&   t   trackparentRp   t   send_modified_eventsRU   t   operatort   eqt   is_equalR   R    t   to_listt   _adapt_listenerRS   t   _active_historyt   expire_missing(   R(   R   R    Rs   R&   Rt   t	   extensiont   compare_functiont   active_historyRp   R|   Ru   RC   t   attrt   ext(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR-   }  s     5							c         C   s   d |  j  j |  j f S(   Ns   %s.%s(   R   RM   R    (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRO     s    c         C   s
   |  j  j S(   s(   Backwards compat for impl.active_history(   R&   R{   (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   _get_active_history  s    c         C   s   | |  j  _ d  S(   N(   R&   R{   (   R(   RY   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   _set_active_history  s    c         C   s=   d } |  j  s t |   | j j t |  j  |  t k	 S(   s4  Return the boolean value of a `hasparent` flag attached to
        the given state.

        The `optimistic` flag determines what the default return value
        should be if no `hasparent` flag can be located.

        As this function is used to determine if an instance is an
        *orphan*, instances that were loaded from storage should be
        assumed to not be orphans, until a True/False value for this
        flag is set.

        An instance attribute that is loaded by a callable function
        will also not have a `hasparent` flag.

        s6   This AttributeImpl is not configured to track parents.(   Rt   R:   t   parentsR]   t   idRp   RH   (   R(   RI   RF   t   msg(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRG     s    c         C   s   d } |  j  s t |   t |  j  } | r@ | | j | <n | | j k r | j | } | t k	 r | j | j k r | j   d k r t	 j
 d t |  t |  |  j f   n  d Sn  t | j | <d S(   s   Set a boolean flag on the given item corresponding to
        whether or not it is attached to a parent object via the
        attribute represented by this ``InstrumentedAttribute``.

        s6   This AttributeImpl is not configured to track parents.s   Removing state %s from parent state %s along attribute '%s', but the parent record has gone stale, can't be sure this is the most recent parent.N(   Rt   R:   R   Rp   R   RH   R    t   objRU   t   orm_exct   StaleDataErrorR   (   R(   RI   t   parent_stateRY   R   t   id_t   last_parent(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   sethasparent  s"    		c         C   s   | | j  |  j <d S(   si  Set a callable function for this attribute on the given object.

        This callable will be executed when the attribute is next
        accessed, and is assumed to construct part of the instances
        previously stored state. When its value or values are loaded,
        they will be established as part of the instance's *committed
        state*.  While *trackparent* information will be assembled for
        these instances, attribute-level event handlers will not be
        fired.

        The callable overrides the class level callable set in the
        ``InstrumentedAttribute`` constructor.

        N(   t	   callablesR    (   R(   RI   Rs   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   set_callable  s    c         C   s   t     d  S(   N(   t   NotImplementedError(   R(   RI   R_   R2   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR0      s    c         C   s   t     d S(   s  Return a list of tuples of (state, obj)
        for all objects in this attribute's current state
        + history.

        Only applies to object-based attributes.

        This is an inlining of existing functionality
        which roughly corresponds to:

            get_state_history(
                        state,
                        key,
                        passive=PASSIVE_NO_INITIALIZE).sum()

        N(   R   (   R(   RI   R_   R2   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   get_all_pending#  s    c         C   s   d | |  j <d S(   s;   Initialize the given state's attribute with an empty value.N(   RU   R    (   R(   RI   R_   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt
   initialize5  s    c         C   sD  |  j  | k r | |  j  S|  j  } | | j k sE | j | t k r"| t @sS t S| | j k r | j | } | | |  } n$ |  j r |  j | |  } n t } | t k s | t k r | S| t k r y | | SWqt	 k
 r t	 d |   qXq"| t k	 r"|  j
 | | |  Sn  | t @s0t S|  j | |  Sd S(   s   Retrieve a value from the given object.
        If a callable is assembled on this object's attribute, and
        passive is False, the callable will be executed and the
        resulting value will be set as the new value for this attribute.
        s=   Deferred loader for attribute %r failed to populate correctlyN(   R    t   committed_stateR   R   R	   R   Rs   R   R
   t   KeyErrort   set_committed_valueR   R   (   R(   RI   R_   R2   R    Rs   RY   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR]   ;  s6    	
	
c         C   s    |  j  | | | | d | d  S(   NR2   (   RX   (   R(   RI   R_   RY   t	   initiatorR2   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   appendg  s    c      	   C   s&   |  j  | | d  | d | d | d  S(   NR2   t	   check_old(   RX   RU   (   R(   RI   R_   RY   R   R2   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   removej  s    c         C   s,   |  j  | | d  | d | d | d t d  S(   NR2   R   t   pop(   RX   RU   RS   (   R(   RI   R_   RY   R   R2   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR   n  s    c         C   s   t     d  S(   N(   R   (   R(   RI   R_   RY   R   R2   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRX   r  s    c         C   sS   |  j  | j k r9 | j |  j  } | t k r2 d S| Sn |  j | | d | Sd S(   s,   return the unchanged value of this attributeR2   N(   R    R   R   RU   R]   (   R(   RI   R_   R2   RY   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   get_committed_valuev  s    c         C   s'   | | |  j  <| j | |  j  g  | S(   s=   set an attribute value on the given instance and 'commit' it.(   R    t   _commit(   R(   RI   R_   RY   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    N(   RM   RQ   RR   RH   RU   RS   R-   RO   R   R   RP   R   RG   R   R   R   R0   R   R   R   R]   R   R   R   RX   R   R   (    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRr   y  s,   I				"		,t   ScalarAttributeImplc           B   s   e  Z d  Z e Z e Z e Z e Z d   Z	 e
 d  Z e
 d
 e d  Z e j d    Z e j d    Z e j d    Z d   Z d   Z e d	    Z RS(   s8   represents a scalar value-holding InstrumentedAttribute.c         C   s   |  j  j r$ |  j | | t  } n | j |  j t  } |  j  j ra |  j | | | |  j  n  | j	 | |  |  | |  j =d  S(   N(
   R&   R{   R]   R   R    R   R   t   fire_remove_eventt   _remove_tokent   _modified_event(   R(   RI   R_   t   old(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR[     s    c         C   s   |  j  | k r) t j |  | | |  j   S| t @r@ | t N} n  |  j | | d | } | t k rh t St j |  | |  Sd  S(   NR2   (   R    t   Historyt   from_scalar_attributeR   R]   R	   t   HISTORY_BLANK(   R(   RI   R_   R2   t   current(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR0     s    
c   	      C   s   |  j  j r$ |  j | | t  } n | j |  j t  } |  j  j rc |  j | | | | |  } n  | j | |  |  | | |  j <d  S(   N(	   R&   R{   R]   R   R    R   RX   t   fire_replace_eventR   (	   R(   RI   R_   RY   R   R2   R   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRX     s    c         C   s   t  |  t  S(   N(   Ro   t
   OP_REPLACE(   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   _replace_token  s    c         C   s   t  |  t  S(   N(   Ro   R   (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   _append_token  s    c         C   s   t  |  t  S(   N(   Ro   t	   OP_REMOVE(   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    c         C   s9   x2 |  j  j D]$ } | | | | | p+ |  j  } q W| S(   N(   R&   RX   R   (   R(   RI   R_   RY   t   previousR   t   fn(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    c         C   s4   x- |  j  j D] } | | | | p( |  j  q Wd  S(   N(   R&   R   R   (   R(   RI   R_   RY   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    c         C   s   |  j  j d j d  S(   Ni    (   RP   t   columnsRL   (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRL     s    N(   RM   RQ   RR   RS   t   accepts_scalar_loaderRH   t   uses_objectsR.   t
   collectionR[   R   R0   RU   RX   R    RV   R   R   R   R   R   RP   RL   (    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s   			t   ScalarObjectAttributeImplc           B   sk   e  Z d  Z e Z e Z e Z e Z d   Z	 e
 d  Z e d  Z e
 d e d  Z d   Z d   Z RS(   s   represents a scalar-holding InstrumentedAttribute,
       where the target object is also instrumented.

       Adds events to delete/set operations.

    c         C   s9   |  j  | |  } |  j | | | |  j  | |  j =d  S(   N(   R]   R   R   R    (   R(   RI   R_   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR[     s    c         C   s   |  j  | k r) t j |  | | |  j   S| t @r@ | t N} n  |  j | | d | } | t k rh t St j |  | |  Sd  S(   NR2   (   R    R   t   from_object_attributeR   R]   R	   R   (   R(   RI   R_   R2   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR0     s    
c         C   s  |  j  | k r | |  j  } n) | t @rD |  j | | d | } n g  S| d  k	 r | t k	 r | t k	 r t |  | f g } n	 d g } |  j  | j k r | j |  j  } | d  k	 r | t k	 r | t k	 r | | k	 r | j t |  | f  q n  | S(   NR2   (   NN(	   R    R   R]   RU   R	   R   R   R   R   (   R(   RI   R_   R2   R   t   rett   original(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s$    
	c   	      C   s   |  j  j r+ |  j | | d t t B} n |  j | | d t } | d k	 r | t k	 r | | k	 r | rq d St d t	 |  t
 |  |  j f   n  |  j | | | | |  } | | |  j <d S(   s1   Set a value on the given InstanceState.

        R2   Ns2   Object %s not associated with %s on attribute '%s'(   R&   R{   R]   R   R   R   RU   R	   t
   ValueErrorR   R   R    R   (	   R(   RI   R_   RY   R   R2   R   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRX     s     			c         C   sx   |  j  r1 | d  k	 r1 |  j t |  | t  n  x- |  j j D] } | | | | pY |  j  q> W| j | |  |  d  S(   N(	   Rt   RU   R   R   RH   R&   R   R   R   (   R(   RI   R_   RY   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR   /  s
    c         C   s   |  j  rI | | k	 rI | d  t t f k rI |  j t |  | t  qI n  x2 |  j j D]$ } | | | | | pt |  j	  } qV W| j
 | |  |  |  j  r | d  k	 r |  j t |  | t  q n  | S(   N(   Rt   RU   R	   R   R   R   RH   R&   RX   R   R   RS   (   R(   RI   R_   RY   R   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR   8  s    		N(   RM   RQ   RR   RH   R   RS   R   R.   R   R[   R   R0   R   R   RU   RX   R   R   (    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s   	!		t   CollectionAttributeImplc           B   s  e  Z d  Z e Z e Z e Z e Z d e d d d d  Z
 d   Z e d  Z e d  Z e j d    Z e j d    Z d   Z d   Z d	   Z d
   Z d   Z d   Z e d  Z e d  Z e d  Z e e d  Z d d  Z d   Z d   Z  d e d  Z! RS(   s  A collection-holding attribute that instruments changes in membership.

    Only handles collections of instrumented objects.

    InstrumentedCollectionAttribute holds an arbitrary, user-specified
    container object (defaulting to a list) and brokers access to the
    CollectionAdapter, a "view" onto that object that presents consistent bag
    semantics to the orm layer independent of the user data implementation.

    c
         K   sb   t  t |   j | | | | d | d | d |	 |
 | d  k rL |  j } n  | |  _ | |  _ d  S(   NRt   R}   R~   (   t   superR   R-   RU   t   _CollectionAttributeImpl__copyt   copyt   collection_factory(   R(   R   R    Rs   R&   t   typecallableRt   R}   t   copy_functionR~   RC   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR-   \  s    		c         C   s    g  t  j |  D] } | ^ q S(   N(   R   t   collection_adapter(   R(   t   itemt   y(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   __copym  s    c         C   s?   |  j  | | d | } | t k r( t St j |  | |  Sd  S(   NR2   (   R]   R	   R   R   t   from_collection(   R(   RI   R_   R2   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR0   p  s    c         C   s  |  j  | k r g  S| |  j  } t | d  } |  j  | j k ry| j |  j  } | t t f k ryg  | D]* } | d  k	 r t |  p d  | f ^ qj } g  | D]* } | d  k	 r t |  p d  | f ^ q } t |  }	 t |  }
 g  | D]$ \ } } | |
 k r | | f ^ q g  | D]$ \ } } | |
 k r| | f ^ qg  | D]$ \ } } | |	 k rM| | f ^ qMSn  g  | D] } t |  | f ^ qS(   Nt   _sa_adapter(   R    RJ   R   R   R   RU   R   t   dict(   R(   RI   R_   R2   R   R   t   ct   current_statest   original_statest   current_sett   original_sett   st   o(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR   w  s"    44] c         C   s   t  |  t  S(   N(   Ro   t	   OP_APPEND(   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    c         C   s   t  |  t  S(   N(   Ro   R   (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    c         C   s}   x/ |  j  j D]! } | | | | p( |  j  } q W| j | |  t t  |  j ry | d  k	 ry |  j t	 |  | t  n  | S(   N(
   R&   R   R   R   R   RS   Rt   RU   R   R   (   R(   RI   R_   RY   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   fire_append_event  s    c         C   s   | j  | |  t t  d  S(   N(   R   R   RS   (   R(   RI   R_   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   fire_pre_remove_event  s    c         C   s{   |  j  r1 | d  k	 r1 |  j t |  | t  n  x- |  j j D] } | | | | pY |  j  q> W| j | |  t	 t
  d  S(   N(   Rt   RU   R   R   RH   R&   R   R   R   R   RS   (   R(   RI   R_   RY   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s
    c         C   sV   |  j  | k r d  S| j | |  t t  |  j | | j  } | j   | |  j  =d  S(   N(   R    R   R   RS   t   get_collectionR   t   clear_with_event(   R(   RI   R_   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR[     s    
c         C   s&   |  j  |  \ } } | | |  j <| S(   s3   Initialize this attribute with an empty collection.(   t   _initialize_collectionR    (   R(   RI   R_   t   _t	   user_data(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    c         C   s   | j  j |  j | |  j  S(   N(   R+   t   initialize_collectionR    R   (   R(   RI   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    	c         C   s   |  j  | | d | } | t k rs |  j | | | |  } |  j | k sW t d   | j |  j  j |  n | j | |  d  S(   NR2   s,   Collection was loaded during event handling.(   R   R	   R   R    R:   t   _get_pending_mutationR   t   append_with_event(   R(   RI   R_   RY   R   R2   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    	c         C   s   |  j  | | j d | } | t k rt |  j | | | |  |  j | k sX t d   | j |  j  j |  n | j | |  d  S(   NR2   s,   Collection was loaded during event handling.(	   R   R   R	   R   R    R:   R   R   t   remove_with_event(   R(   RI   R_   RY   R   R2   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    	c         C   sA   y  |  j  | | | | d | Wn t t t f k
 r< n Xd  S(   NR2   (   R   R   R   t
   IndexError(   R(   RI   R_   RY   R   R2   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s     c         C   s   |  j  | | | d    d S(   s*   Set a value on the given object.

        c         S   s   |  j  |  S(   N(   t   adapt_like_to_iterable(   t   adaptert   i(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   <lambda>  s    N(   t   _set_iterable(   R(   RI   R_   RY   R   R2   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyRX     s    	c   
      C   s   |  j  |  \ } } | r3 t | | |   } n t |  } |  j | | d t } | t k rx |  j | |  } n | | k r d S| j | |  | t  t | d  }	 | | |  j	 <t
 j | |	 |  |	 j |  d S(   s  Set a collection value from an iterable of state-bearers.

        ``adapter`` is an optional callable invoked with a CollectionAdapter
        and the iterable.  Should return an iterable of state-bearing
        instances suitable for appending via a CollectionAdapter.  Can be used
        for, e.g., adapting an incoming dictionary into an iterator of values
        rather than keys.

        R2   NR   (   R   t   listR]   R   R	   R   R   RS   RJ   R    R   t   bulk_replacet   unlink(
   R(   RI   R_   t   iterableR   t   new_collectionR   t
   new_valuesR   t   old_collection(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    c         C   s   t  | d  } t | _ d  S(   NR   (   RJ   RS   t   invalidated(   R(   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   _invalidate_collection  s    c   
      C   s   |  j  |  \ } } | r+ | j |  n  | | j |  j <| j | |  j g  |  j | j k r | j | |  | t  | j j |  j  } | j	 } | j
 } x | D] }	 | j |	  q Wx | D] }	 | j |	  q Wn  | S(   s=   Set an attribute value on the given instance and 'commit' it.(   R   t   append_multiple_without_eventR   R    R   t   _pending_mutationsR   RS   R   t   added_itemst   deleted_itemst   append_without_eventt   remove_without_event(
   R(   RI   R_   RY   R   R   t   pendingt   addedt   removedR   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    		c         C   sD   | d k r7 |  j | | d | } | t k r7 | Sn  t | d  S(   s   Retrieve the CollectionAdapter associated with the given state.

        Creates a new CollectionAdapter if one does not exist.

        R2   R   N(   RU   R]   R	   RJ   (   R(   RI   R_   R   R2   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR   6  s
    N("   RM   RQ   RR   RH   R   RS   R   R.   R   RU   R-   R   R   R0   R   R   R    RV   R   R   R   R   R   R[   R   R   R   R   R   RX   R   R   R   R   (    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR   K  s4   		 							


	$		c            s    j  j    j    f d         f d   }     f d   }  f d   } | r t j  d | d t d t n t j  d | d t d t t j  d	 | d t d t d
 S(   s6   Apply listeners to synchronize a two-way relationship.c            s2   t  d t |   | j | j   j j f   d  S(   Ns   Bidirectional attribute conflict detected: Passing object %s to attribute "%s" triggers a modify event on attribute "%s" via the backref "%s".(   R   R   Rp   R!   (   t   child_stateR   t
   child_impl(   Rh   (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   _acceptable_key_errM  s    	c   
         se  | | k r | S| d  k	 r | t k	 r | t k	 r t |  t |  } } | j  j } | j | k	 s | j t t	 f k r | j
 | | |  j    j d t q n  | d  k	 rat |  t |  } } | j  j }	 | j   k	 r| j |	 j k	 r |  | |	  qa| j |	 k	 s9| j t t f k ra|	 j | | |  j   | d t qan  | S(   NR2   (   RU   R	   R   R   R   R+   R!   RA   R   R   R   R   R   R   Rp   R   R   (
   RI   t   childt   oldchildR   t	   old_statet   old_dictR!   R   t
   child_dictR   (   Rp   R   t   parent_implR    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt"   emit_backref_from_scalar_set_eventZ  s>    						c      	      s   | d  k r d  St |  t |  } } | j  j } | j  k	 rm | j | j k	 rm   |  | |  nI | j | k	 s | j t t f k r | j	 | | |  j
   | d t n  | S(   NR2   (   RU   R   R   R+   R!   Rp   RA   R   R   R   R   R   (   RI   R   R   R   R   R   (   R   Rp   R    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt)   emit_backref_from_collection_append_event  s"    		
c            s   | d  k	 r t |  t |  } } | j   j } | j | k	 sY | j t t f k r | j | | |  j	   | d t
 q n  d  S(   NR2   (   RU   R   R   R+   R!   RA   R   R   R   R   R   (   RI   R   R   R   R   R   (   R    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt)   emit_backref_from_collection_remove_event  s    		R   t   retvalt   rawRX   R   N(   R!   Rp   R   t   listenRS   (   Rh   R    t   uselistR   R   R   (    (   Rp   Rh   R   R   R    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   backref_listenersE  s     	%t
   NO_HISTORYR   R   t	   unchangedt   deletedc           B   s   e  Z d  Z d   Z e Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 e d    Z e d	    Z e d
    Z RS(   s  A 3-tuple of added, unchanged and deleted values,
    representing the changes which have occurred on an instrumented
    attribute.

    The easiest way to get a :class:`.History` object for a particular
    attribute on an object is to use the :func:`.inspect` function::

        from sqlalchemy import inspect

        hist = inspect(myobject).attrs.myattribute.history

    Each tuple member is an iterable sequence:

    * ``added`` - the collection of items added to the attribute (the first
      tuple element).

    * ``unchanged`` - the collection of items that have not changed on the
      attribute (the second tuple element).

    * ``deleted`` - the collection of items that have been removed from the
      attribute (the third tuple element).

    c         C   s
   |  t  k S(   N(   R   (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   __bool__  s    c         C   s    t  |  j p |  j p |  j  S(   sh   Return True if this :class:`.History` has no changes
        and no existing, unchanged state.

        (   t   boolR   R  R  (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   empty  s    c         C   s'   |  j  p g  |  j p g  |  j p% g  S(   s3   Return a collection of added + unchanged + deleted.(   R   R  R  (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   sum  s    c         C   s   |  j  p g  |  j p g  S(   s)   Return a collection of added + unchanged.(   R   R  (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   non_deleted  s    c         C   s   |  j  p g  |  j p g  S(   s+   Return a collection of unchanged + deleted.(   R  R  (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt	   non_added  s    c         C   s   t  |  j p |  j  S(   s2   Return True if this :class:`.History` has changes.(   R  R   R  (   R(   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   has_changes  s    c         C   s   t  g  |  j D]$ } | d  k	 r+ t |  p. d  ^ q g  |  j D]$ } | d  k	 r\ t |  p_ d  ^ q> g  |  j D]$ } | d  k	 r t |  p d  ^ qo  S(   N(   R   R   RU   R   R  R  (   R(   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   as_state  s    ..c         C   s   | j  j | j t  } | t k rV | t k r@ |  d d d  S|  d | g d  Sn~ | j | |  t k r |  d | g d  St |  t k r d } n	 | g } | t k r |  d	 d
 |  S|  | g d |  Sd  S(   N(    (    (    (    (    (    (    (    (    (    (    (	   R   R]   R    t   _NO_HISTORYR   Rx   RS   R   t   _NO_STATE_SYMBOLS(   R>   Rh   RI   R   R   R  (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    		c         C   s   | j  j | j t  } | t k rb | t k s< | t k rL |  d d d  S|  d | g d  Sn | | k r |  d | g d  St |  t k s | d  k r d } n	 | g } | t k s | t k r |  d	 d
 |  S|  | g d |  Sd  S(   N(    (    (    (    (    (    (    (    (    (    (    (	   R   R]   R    R  R   R   R   R  RU   (   R>   Rh   RI   R   R   R  (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR   #  s    		c         C   s  | j  j | j t  } | t k s0 | t k r@ |  d d d  St | d  } | t t f k rw |  t |  d d  S| t k r |  d t |  d  Sg  | D]* } | d  k	 r t	 |  p d  | f ^ q } g  | D]* } | d  k	 r t	 |  p d  | f ^ q } t
 |  } t
 |  }	 |  g  | D] \ }
 } |
 |	 k r)| ^ q)g  | D] \ }
 } |
 |	 k rQ| ^ qQg  | D] \ }
 } |
 | k ry| ^ qy Sd  S(	   NR   (    (    (    (    (    (    (    (   R   R]   R    R  R   R   RJ   R   RU   R   R   (   R>   Rh   RI   R   R   R   R   R   R   R   R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR   =  s$    44(((   RM   RQ   RR   R  t   __nonzero__R  R  R  R  R	  R
  t   classmethodR   R   R   (    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s   							c         C   sZ   | t  k r" t j d  t } n" | t k rD t j d  t } n  t t |   | |  S(   s  Return a :class:`.History` record for the given object
    and attribute key.

    :param obj: an object whose class is instrumented by the
      attributes package.

    :param key: string attribute name.

    :param passive: indicates loading behavior for the attribute
       if the value is not already present.   This is a
       bitflag attribute, which defaults to the symbol
       :attr:`.PASSIVE_OFF` indicating all necessary SQL
       should be emitted.

    sN   Passing True for 'passive' is deprecated. Use attributes.PASSIVE_NO_INITIALIZEsF   Passing False for 'passive' is deprecated.  Use attributes.PASSIVE_OFF(   RS   R    t   warn_deprecatedR   RH   R   t   get_state_historyR   (   R   R    R2   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR0   `  s    		c         C   s   |  j  | |  S(   N(   R0   (   RI   R    R2   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR  |  s    c         C   s+   t  |   } t |  } | j | | |  S(   t   TODO(   R   R   t
   has_parent(   R>   R   R    RF   R+   RI   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR    s    c         K   se   | j  d d   } | j  d d   } | j  d d   } t |  | | | d | } t |  | |  | S(   NR"   R)   Rf   (   R   RU   t   register_descriptort   register_attribute_impl(   R   R    t   kwR"   R)   Rf   t   desc(    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   register_attribute  s    	c      	   K   s  t  |   } | r? | j d d   }	 | j | |	 p6 t  }
 n | j d d   }
 | | j } | r | |  | |
 | |  } n` | r t |  | | | d |
 | } n9 | r t |  | | | |  } n t |  | | | |  } | | | _	 | r	t
 | | | |  n  | j |  | | S(   NR   (   R   R   RU   t   instrument_collection_classR   R&   R   R   R   R!   R   t   post_configure_attribute(   R   R    R   Rs   t	   useobjectt
   impl_classt   backrefR  R+   t   factoryR   R&   R!   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR    s*    c         C   sD   t  |   } t |  | d | d | } | | _ | j | |  | S(   NR"   R)   (   R   RW   RR   t   instrument_attribute(   R   R    R"   R)   Rf   R+   Rb   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR    s    		c         C   s   t  |   j |  d  S(   N(   R   t   uninstrument_attribute(   R   R    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   unregister_attribute  s    c         C   s%   t  |   } | j } t | | |  S(   sa  Initialize a collection attribute and return the collection adapter.

    This function is used to provide direct access to collection internals
    for a previously unloaded attribute.  e.g.::

        collection_adapter = init_collection(someobject, 'elements')
        for elem in values:
            collection_adapter.append_without_event(elem)

    For an easier way to do the above, see
    :func:`~sqlalchemy.orm.attributes.set_committed_value`.

    obj is an instrumented object instance.  An InstanceState
    is accepted directly for backwards compatibility but
    this usage is deprecated.

    (   R   R   t   init_state_collection(   R   R    RI   R_   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   init_collection  s    	c         C   s5   |  j  | j } | j |  |  } | j |  | |  S(   sD   Initialize a collection attribute and return the collection adapter.(   R+   R!   R   R   (   RI   R_   R    R   R   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR!    s    c         C   s:   t  |   t |   } } | j | j j | | |  d S(   s[  Set the value of an attribute with no history events.

    Cancels any previous history present.  The value should be
    a scalar value for scalar-holding attributes, or
    an iterable for any collection-holding attribute.

    This is the same underlying method used when a lazy loader
    fires off and loads additional data from the database.
    In particular, this method can be used by application code
    which has loaded additional attributes or collections through
    separate queries, which can then be attached to an instance
    as though it were part of its original loaded state.

    N(   R   R   R+   R!   R   (   R1   R    RY   RI   R_   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyR     s    c         C   s=   t  |   t |   } } | j | j j | | | d  d S(   sN  Set the value of an attribute, firing history events.

    This function may be used regardless of instrumentation
    applied directly to the class, i.e. no descriptors are required.
    Custom attribute management schemes will need to make usage
    of this method to establish attribute state as understood
    by SQLAlchemy.

    N(   R   R   R+   R!   RX   RU   (   R1   R    RY   RI   R_   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   set_attribute  s    
c         C   s3   t  |   t |   } } | j | j j | |  S(   sZ  Get the value of an attribute, firing any callables required.

    This function may be used regardless of instrumentation
    applied directly to the class, i.e. no descriptors are required.
    Custom attribute management schemes will need to make usage
    of this method to make usage of attribute state as understood
    by SQLAlchemy.

    (   R   R   R+   R!   R]   (   R1   R    RI   R_   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   get_attribute  s    
c         C   s7   t  |   t |   } } | j | j j | |  d S(   sQ  Delete the value of an attribute, firing history events.

    This function may be used regardless of instrumentation
    applied directly to the class, i.e. no descriptors are required.
    Custom attribute management schemes will need to make usage
    of this method to establish attribute state as understood
    by SQLAlchemy.

    N(   R   R   R+   R!   R[   (   R1   R    RI   R_   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   del_attribute  s    
c         C   sF   t  |   t |   } } | j | j } | j | | t d t d S(   s   Mark an attribute on an instance as 'modified'.

    This sets the 'modified' flag on the instance and
    establishes an unconditional change event for the given attribute.

    t   forceN(   R   R   R+   R!   R   R   RS   (   R1   R    RI   R_   R!   (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   flag_modified!  s    (L   RR   Rv   t    R    R   R   R   R   R   R   R,   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   _self_inspectst   _MappedAttributet   _InspectionAttrt   PropComparatorR   RW   Rk   t   symbolR   R   R   t   objectRo   Rr   R   R   R   R   R  t	   frozensetR   R  t
   namedtupleR   RU   R   R0   R  RH   R  R  R  R  R   R"  R!  R   R#  R$  R%  R'  (    (    (    s_   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/attributes.pyt   <module>   s`   |		U- Jw	j				 							