
H`Tc           @   s  d  Z  d d l m Z m Z m Z d d l m Z d d l Z d d l Z d d l m	 Z	 d d l m
 Z
 m Z d d	 l m Z m Z d d
 l m Z d d l m Z d e j f d     YZ d e f d     YZ d e j f d     YZ d e j f d     YZ d e f d     YZ d e j f d     YZ d e f d     YZ d e j f d     YZ d e j f d     YZ d S(   s   ORM event interfaces.

i   (   t   eventt   exct   utili   (   t   _mapper_or_noneiN(   t
   interfaces(   t	   mapperlibt   instrumentation(   t   Sessiont   sessionmaker(   t   scoped_session(   t   QueryableAttributet   InstrumentationEventsc           B   sh   e  Z d  Z d Z e j Z e d    Z e e	 d   Z
 e d    Z d   Z d   Z d   Z RS(   sq  Events related to class instrumentation events.

    The listeners here support being established against
    any new style class, that is any object that is a subclass
    of 'type'.  Events will then be fired off for events
    against that class.  If the "propagate=True" flag is passed
    to event.listen(), the event will fire off for subclasses
    of that class as well.

    The Python ``type`` builtin is also accepted as a target,
    which when used has the effect of events being emitted
    for all classes.

    Note the "propagate" flag here is defaulted to ``True``,
    unlike the other class level events where it defaults
    to ``False``.  This means that new subclasses will also
    be the subject of these events, when a listener
    is established on a superclass.

    .. versionchanged:: 0.8 - events here will emit based
       on comparing the incoming class to the type of class
       passed to :func:`.event.listen`.  Previously, the
       event would fire for any class unconditionally regardless
       of what class was sent for listening, despite
       documentation which stated the contrary.

    t   SomeBaseClassc         C   s!   t  | t  r t |  Sd  Sd  S(   N(   t
   isinstancet   typet   _InstrumentationEventsHoldt   None(   t   clst   target(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   _accept_with6   s    
c            s   | j  | j | j       f d        f d   } t j  j |   | j t j  j	    j
 |   d  S(   Nc            sO       }  r+ t  |  |  r+  |  |  S rK |  | k rK  |  |  Sd  S(   N(   t
   issubclass(   t
   target_clst   argt
   listen_cls(   R   t	   propagatet   fn(    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   listenC   s
    	c            s>   t  j j d     t j  } t t j j    j |  d  S(   N(	   R    t   registryt	   _EventKeyR   R   t   _instrumentation_factoryt   getattrt   dispatcht   remove(   t   reft   key(   t
   identifierR   (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR    J   s
    		(   t   dispatch_targetR#   t
   _listen_fnt   weakrefR!   t   class_t   with_dispatch_targetR   R   t   with_wrappert   base_listen(   R   t	   event_keyR   t   kwR    (    (   R   R   R   R#   R   s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   _listen=   s    c         C   s'   t  t |   j   t j j j   d  S(   N(   t   superR   t   _clearR   R   R   (   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR/   W   s    c         C   s   d S(   s   Called after the given class is instrumented.

        To get at the :class:`.ClassManager`, use
        :func:`.manager_of_class`.

        N(    (   t   selfR   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   class_instrument\   s    c         C   s   d S(   s   Called before the given class is uninstrumented.

        To get at the :class:`.ClassManager`, use
        :func:`.manager_of_class`.

        N(    (   R0   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   class_uninstrumentd   s    c         C   s   d S(   s)   Called when an attribute is instrumented.N(    (   R0   R   R"   t   inst(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   attribute_instrumentl   s    (   t   __name__t
   __module__t   __doc__t   _target_class_docR   t   InstrumentationFactoryt   _dispatch_targett   classmethodR   t   TrueR-   R/   R1   R2   R4   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR      s   			R   c           B   s&   e  Z d  Z d   Z e j e  Z RS(   sw   temporary marker object used to transfer from _accept_with() to
    _listen() on the InstrumentationEvents class.

    c         C   s   | |  _  d  S(   N(   R'   (   R0   R'   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   __init__v   s    (   R5   R6   R7   R=   R    t
   dispatcherR   R   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR   p   s   	t   InstanceEventsc           B   s   e  Z d  Z d Z e j Z e d    Z e e	 j
 d  d     Z e e e d   Z e d    Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   sC  Define events specific to object lifecycle.

    e.g.::

        from sqlalchemy import event

        def my_load_listener(target, context):
            print "on load!"

        event.listen(SomeClass, 'load', my_load_listener)

    Available targets include:

    * mapped classes
    * unmapped superclasses of mapped or to-be-mapped classes
      (using the ``propagate=True`` flag)
    * :class:`.Mapper` objects
    * the :class:`.Mapper` class itself and the :func:`.mapper`
      function indicate listening for all mappers.

    .. versionchanged:: 0.8.0 instance events can be associated with
       unmapped superclasses of mapped classes.

    Instance events are closely related to mapper events, but
    are more specific to the instance and its instrumentation,
    rather than its system of persistence.

    When using :class:`.InstanceEvents`, several modifiers are
    available to the :func:`.event.listen` function.

    :param propagate=False: When True, the event listener should
       be applied to all inheriting classes as well as the
       class which is the target of this listener.
    :param raw=False: When True, the "target" argument passed
       to applicable event listener functions will be the
       instance's :class:`.InstanceState` management
       object, rather than the mapped instance itself.

    t	   SomeClassc         C   s   t  j | |  d  S(   N(   t   _InstanceEventsHoldt   populate(   R   R'   t   classmanager(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   _new_classmanager_instance   s    s   sqlalchemy.ormc         C   s   t  | t j  r | St  | t j  r/ | j S| | j k rE t j St  | t  r t | t j  rm t j St j	 |  } | r | St
 |  Sn  d  S(   N(   R   R   t   ClassManagerR   t   Mappert   class_managert   mapperR   R   t   manager_of_classRA   R   (   R   t   ormR   t   manager(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR      s    c   	         s   | j  | j | j } }   | sD   f d   } | j |  } n  | j d | |  | r x3 | j t  D] } | j |  j d t  qm Wn  d  S(   Nc            s     |  j    | |  S(   N(   t   obj(   t   stateR   R,   (   R   (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   wrap   s    R   (   R$   R#   R%   R)   R*   t   subclass_managersR<   R(   (	   R   R+   t   rawR   R,   R   R#   RN   t   mgr(    (   R   s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR-      s    c         C   s!   t  t |   j   t j   d  S(   N(   R.   R?   R/   RA   (   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR/      s    c         C   s   d S(   sK   Called when the first instance of a particular mapping is called.

        N(    (   R0   RK   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt
   first_init   s    c         C   s   d S(   s   Receive an instance when its constructor is called.

        This method is only called during a userland construction of
        an object.  It is not called when an object is loaded from the
        database.

        N(    (   R0   R   t   argst   kwargs(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   init   s    c         C   s   d S(   s  Receive an instance when its constructor has been called,
        and raised an exception.

        This method is only called during a userland construction of
        an object.  It is not called when an object is loaded from the
        database.

        N(    (   R0   R   RS   RT   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   init_failure   s    c         C   s   d S(   s*  Receive an object instance after it has been created via
        ``__new__``, and after initial attribute population has
        occurred.

        This typically occurs when the instance is created based on
        incoming result rows, and is only called once for that
        instance's lifetime.

        Note that during a result-row load, this method is called upon
        the first row received for this instance.  Note that some
        attributes and collections may or may not be loaded or even
        initialized, depending on what's present in the result rows.

        :param target: the mapped instance.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :param context: the :class:`.QueryContext` corresponding to the
         current :class:`.Query` in progress.  This argument may be
         ``None`` if the load does not correspond to a :class:`.Query`,
         such as during :meth:`.Session.merge`.

        N(    (   R0   R   t   context(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   load   s    c         C   s   d S(   sj  Receive an object instance after one or more attributes have
        been refreshed from a query.

        :param target: the mapped instance.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :param context: the :class:`.QueryContext` corresponding to the
         current :class:`.Query` in progress.
        :param attrs: iterable collection of attribute names which
         were populated, or None if all column-mapped, non-deferred
         attributes were populated.

        N(    (   R0   R   RW   t   attrs(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   refresh	  s    c         C   s   d S(   s*  Receive an object instance after its attributes or some subset
        have been expired.

        'keys' is a list of attribute names.  If None, the entire
        state was expired.

        :param target: the mapped instance.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :param attrs: iterable collection of attribute
         names which were expired, or None if all attributes were
         expired.

        N(    (   R0   R   RY   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   expire  s    c         C   s   d S(   sy  Receive an object instance as it is 'resurrected' from
        garbage collection, which occurs when a "dirty" state falls
        out of scope.

        :param target: the mapped instance.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.

        .. deprecated:: 0.9 - the resurrect event has no function, as the
           underlying functionality was dependent on the "mutation tracking"
           feature removed from SQLAlchemy in the 0.8 series.   This event
           is removed in 1.0.

        N(    (   R0   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt	   resurrect*  s    c         C   s   d S(   s  Receive an object instance when its associated state is
        being pickled.

        :param target: the mapped instance.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :param state_dict: the dictionary returned by
         :class:`.InstanceState.__getstate__`, containing the state
         to be pickled.

        N(    (   R0   R   t
   state_dict(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   pickle;  s    c         C   s   d S(   s  Receive an object instance after its associated state has
        been unpickled.

        :param target: the mapped instance.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :param state_dict: the dictionary sent to
         :class:`.InstanceState.__setstate__`, containing the state
         dictionary which was pickled.

        N(    (   R0   R   R]   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   unpickleI  s    (   R5   R6   R7   R8   R   RE   R:   R;   RD   R   t   dependenciesR   t   FalseR-   R/   RR   RU   RV   RX   RZ   R[   R\   R^   R_   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR?   |   s$   '					
					t   _EventsHoldc           B   sT   e  Z d  Z d   Z e d    Z d e f d     YZ d   Z e d    Z	 RS(   s   Hold onto listeners against unmapped, uninstrumented classes.

    Establish _listen() for that class' mapper/instrumentation when
    those objects are created for that class.

    c         C   s   | |  _  d  S(   N(   R'   (   R0   R'   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR=   `  s    c         C   s   |  j  j   d  S(   N(   t	   all_holdst   clear(   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR/   c  s    t
   HoldEventsc           B   s#   e  Z d Z e e e d    Z RS(   c         K   s  | j  | j | j } } } | j | j k rB | j | j } n i  } | j | j <t j j | |  | | | f | | j <| rt	 | j j
    }	 xo |	 r|	 j d  }
 |	 j |
 j
    | j |
  } | d  k	 r | j |  j d | d t |  q q Wn  d  S(   Ni    RP   R   (   R$   R#   R   R'   Rc   R    R   t   _stored_in_collectiont   _keyt   listt   __subclasses__t   popt   extendt   resolveR   R(   R   Ra   (   R   R+   RP   R   R,   R   R#   R   t
   collectiont   stackt   subclasst   subject(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR-   j  s    	N(   R5   R6   R   R:   R;   Ra   R-   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRe   g  s   c         C   sM   | j  | j | j } } } t | t  rI | j | j } | | j =n  d  S(   N(   R$   R#   R   R   Rb   Rc   R'   Rg   (   R0   R+   R   R#   R   Rm   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR      s    c         C   s   x | j  D]y } | |  j k r
 |  j | } xT | j   D]C \ } } } | sZ | | k r9 | j |  j d | d t  q9 q9 Wq
 q
 Wd  S(   NRP   R   (   t   __mro__Rc   t   valuesR(   R   Ra   (   R   R'   Rp   Ro   Rm   R+   RP   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRB     s    (
   R5   R6   R7   R=   R;   R/   t   objectRe   R    RB   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRb   X  s   		RA   c           B   sH   e  Z e j   Z d    Z d e j e f d     YZ	 e
 j e	  Z RS(   c         C   s   t  j |  S(   N(   R   RI   (   R0   R'   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRl     s    t   HoldInstanceEventsc           B   s   e  Z RS(    (   R5   R6   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRt     s   (   R5   R6   R&   t   WeakKeyDictionaryRc   Rl   Rb   Re   R?   Rt   R    R>   R   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRA     s   	t   MapperEventsc           B   s   e  Z d  Z d Z e j Z e d    Z e e	 j
 d  d     Z e e e e d   Z e d    Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   sT  Define events specific to mappings.

    e.g.::

        from sqlalchemy import event

        def my_before_insert_listener(mapper, connection, target):
            # execute a stored procedure upon INSERT,
            # apply the value to the row to be inserted
            target.calculated_value = connection.scalar(
                                        "select my_special_function(%d)"
                                        % target.special_number)

        # associate the listener function with SomeClass,
        # to execute during the "before_insert" hook
        event.listen(
            SomeClass, 'before_insert', my_before_insert_listener)

    Available targets include:

    * mapped classes
    * unmapped superclasses of mapped or to-be-mapped classes
      (using the ``propagate=True`` flag)
    * :class:`.Mapper` objects
    * the :class:`.Mapper` class itself and the :func:`.mapper`
      function indicate listening for all mappers.

    .. versionchanged:: 0.8.0 mapper events can be associated with
       unmapped superclasses of mapped classes.

    Mapper events provide hooks into critical sections of the
    mapper, including those related to object instrumentation,
    object loading, and object persistence. In particular, the
    persistence methods :meth:`~.MapperEvents.before_insert`,
    and :meth:`~.MapperEvents.before_update` are popular
    places to augment the state being persisted - however, these
    methods operate with several significant restrictions. The
    user is encouraged to evaluate the
    :meth:`.SessionEvents.before_flush` and
    :meth:`.SessionEvents.after_flush` methods as more
    flexible and user-friendly hooks in which to apply
    additional database state during a flush.

    When using :class:`.MapperEvents`, several modifiers are
    available to the :func:`.event.listen` function.

    :param propagate=False: When True, the event listener should
       be applied to all inheriting mappers and/or the mappers of
       inheriting classes, as well as any
       mapper which is the target of this listener.
    :param raw=False: When True, the "target" argument passed
       to applicable event listener functions will be the
       instance's :class:`.InstanceState` management
       object, rather than the mapped instance itself.
    :param retval=False: when True, the user-defined event function
       must have a return value, the purpose of which is either to
       control subsequent event propagation, or to otherwise alter
       the operation in progress by the mapper.   Possible return
       values are:

       * ``sqlalchemy.orm.interfaces.EXT_CONTINUE`` - continue event
         processing normally.
       * ``sqlalchemy.orm.interfaces.EXT_STOP`` - cancel all subsequent
         event handlers in the chain.
       * other values - the return value specified by specific listeners.

    R@   c         C   s   t  j | |  d  S(   N(   t   _MapperEventsHoldRB   (   R   R'   RH   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   _new_mapper_instance  s    s   sqlalchemy.ormc         C   sl   | | j  k r t j St | t  rd t | t j  r; | St |  } | d  k	 rW | St |  Sn | Sd  S(   N(	   RH   R   RF   R   R   R   R   R   Rw   (   R   RJ   R   RH   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR     s    c            s   | j  | j | j } }  | d	 k rH | t j k	 rH t j d  n   sV  r  s t |  |  } y$ t j	 |  d j
 d  d   Wq t k
 r d    q Xn       f d   }	 | j |	  } n  | rx= | j D]" }
 | j |
  j d t |  q Wn | j |   d  S(
   Nt   before_configuredt   after_configureds{   'before_configured' and 'after_configured' ORM events only invoke with the mapper() function or Mapper class as the target.i    R   i   c             sa    r6   d  k	 r6 t |   }  |    j   |    <n   sP  |  |   t j S |  |   Sd  S(   N(   R   Rh   RL   R   t   EXT_CONTINUE(   R   R,   (   t   target_indexRP   t   retvalR   (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRN     s    R   (   s   before_configureds   after_configured(   R$   R#   R%   R   RF   R   t   warnR   t   inspectt
   getargspect   indext
   ValueErrorR   R)   t   self_and_descendantsR(   R*   R<   (   R   R+   RP   R}   R   R,   R   R#   t   methRN   RH   (    (   R|   RP   R}   R   s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR-     s(    
$	c         C   s!   t  t |   j   t j   d  S(   N(   R.   Rv   R/   Rw   (   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR/   -  s    c         C   s   d S(   s  Receive a class when the mapper is first constructed,
        before instrumentation is applied to the mapped class.

        This event is the earliest phase of mapper construction.
        Most attributes of the mapper are not yet initialized.

        This listener can either be applied to the :class:`.Mapper`
        class overall, or to any un-mapped class which serves as a base
        for classes that will be mapped (using the ``propagate=True`` flag)::

            Base = declarative_base()

            @event.listens_for(Base, "instrument_class", propagate=True)
            def on_new_class(mapper, cls_):
                " ... "

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param class\_: the mapped class.

        N(    (   R0   RH   R'   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   instrument_class2  s    c         C   s   d S(   s  Called when the mapper for the class is fully configured.

        This event is the latest phase of mapper construction, and
        is invoked when the mapped classes are first used, so that
        relationships between mappers can be resolved.   When the event is
        called, the mapper should be in its final state.

        While the configuration event normally occurs automatically,
        it can be forced to occur ahead of time, in the case where the event
        is needed before any actual mapper usage,  by using the
        :func:`.configure_mappers` function.


        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param class\_: the mapped class.

        N(    (   R0   RH   R'   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   mapper_configuredI  s    c         C   s   d S(   s  Called before a series of mappers have been configured.

        This corresponds to the :func:`.orm.configure_mappers` call, which
        note is usually called automatically as mappings are first
        used.

        This event can **only** be applied to the :class:`.Mapper` class
        or :func:`.mapper` function, and not to individual mappings or
        mapped classes.  It is only invoked for all mappings as a whole::

            from sqlalchemy.orm import mapper

            @event.listens_for(mapper, "before_configured")
            def go():
                # ...

        Theoretically this event is called once per
        application, but is actually called any time new mappers
        are to be affected by a :func:`.orm.configure_mappers`
        call.   If new mappings are constructed after existing ones have
        already been used, this event can be called again.  To ensure
        that a particular event is only called once and no further, the
        ``once=True`` argument (new in 0.9.4) can be applied::

            from sqlalchemy.orm import mapper

            @event.listens_for(mapper, "before_configured", once=True)
            def go():
                # ...


        .. versionadded:: 0.9.3

        N(    (   R0   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRy   ^  s    c         C   s   d S(   s  Called after a series of mappers have been configured.

        This corresponds to the :func:`.orm.configure_mappers` call, which
        note is usually called automatically as mappings are first
        used.

        This event can **only** be applied to the :class:`.Mapper` class
        or :func:`.mapper` function, and not to individual mappings or
        mapped classes.  It is only invoked for all mappings as a whole::

            from sqlalchemy.orm import mapper

            @event.listens_for(mapper, "after_configured")
            def go():
                # ...

        Theoretically this event is called once per
        application, but is actually called any time new mappers
        have been affected by a :func:`.orm.configure_mappers`
        call.   If new mappings are constructed after existing ones have
        already been used, this event can be called again.  To ensure
        that a particular event is only called once and no further, the
        ``once=True`` argument (new in 0.9.4) can be applied::

            from sqlalchemy.orm import mapper

            @event.listens_for(mapper, "after_configured", once=True)
            def go():
                # ...

        N(    (   R0   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRz     s    c         C   s   d S(   so  Perform pre-processing on the given result row and return a
        new row instance.

        .. deprecated:: 0.9 the :meth:`.translate_row` event should
           be considered as legacy.  The row as delivered in a mapper
           load operation typically requires that highly technical
           details be accommodated in order to identity the correct
           column keys are present in the row, rendering this particular
           event hook as difficult to use and unreliable.

        This listener is typically registered with ``retval=True``.
        It is called when the mapper first receives a row, before
        the object identity or the instance itself has been derived
        from that row.   The given row may or may not be a
        :class:`.RowProxy` object - it will always be a dictionary-like
        object which contains mapped columns as keys.  The
        returned object should also be a dictionary-like object
        which recognizes mapped columns as keys.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param context: the :class:`.QueryContext`, which includes
         a handle to the current :class:`.Query` in progress as well
         as additional state information.
        :param row: the result row being handled.  This may be
         an actual :class:`.RowProxy` or may be a dictionary containing
         :class:`.Column` objects as keys.
        :return: When configured with ``retval=True``, the function
         should return a dictionary-like row object, or ``EXT_CONTINUE``,
         indicating the original row should be used.


        N(    (   R0   RH   RW   t   row(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   translate_row  s    c         C   s   d S(   s  Receive a row when a new object instance is about to be
        created from that row.

        .. deprecated:: 0.9 the :meth:`.create_instance` event should
           be considered as legacy.  Manipulation of the object construction
           mechanics during a load should not be necessary.

        The method can choose to create the instance itself, or it can return
        EXT_CONTINUE to indicate normal object creation should take place.
        This listener is typically registered with ``retval=True``.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param context: the :class:`.QueryContext`, which includes
         a handle to the current :class:`.Query` in progress as well
         as additional state information.
        :param row: the result row being handled.  This may be
         an actual :class:`.RowProxy` or may be a dictionary containing
         :class:`.Column` objects as keys.
        :param class\_: the mapped class.
        :return: When configured with ``retval=True``, the return value
         should be a newly created instance of the mapped class,
         or ``EXT_CONTINUE`` indicating that default object construction
         should take place.

        N(    (   R0   RH   RW   R   R'   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   create_instance  s    c         K   s   d S(   sy  Receive an object instance before that instance is appended
        to a result list.

        .. deprecated:: 0.9 the :meth:`.append_result` event should
           be considered as legacy.  It is a difficult to use method
           whose original purpose is better suited by custom collection
           classes.

        This is a rarely used hook which can be used to alter
        the construction of a result list returned by :class:`.Query`.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param context: the :class:`.QueryContext`, which includes
         a handle to the current :class:`.Query` in progress as well
         as additional state information.
        :param row: the result row being handled.  This may be
         an actual :class:`.RowProxy` or may be a dictionary containing
         :class:`.Column` objects as keys.
        :param target: the mapped instance being populated.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :param result: a list-like object where results are being
         appended.
        :param \**flags: Additional state information about the
         current handling of the row.
        :return: If this method is registered with ``retval=True``,
         a return value of ``EXT_STOP`` will prevent the instance
         from being appended to the given result list, whereas a
         return value of ``EXT_CONTINUE`` will result in the default
         behavior of appending the value to the result list.

        N(    (   R0   RH   RW   R   R   t   resultt   flags(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   append_result  s    c         K   s   d S(   s  Receive an instance before that instance has
        its attributes populated.

        .. deprecated:: 0.9 the :meth:`.populate_instance` event should
           be considered as legacy.  The mechanics of instance population
           should not need modification; special "on load" rules can as always
           be accommodated by the :class:`.InstanceEvents.load` event.

        This usually corresponds to a newly loaded instance but may
        also correspond to an already-loaded instance which has
        unloaded attributes to be populated.  The method may be called
        many times for a single instance, as multiple result rows are
        used to populate eagerly loaded collections.

        Most usages of this hook are obsolete.  For a
        generic "object has been newly created from a row" hook, use
        :meth:`.InstanceEvents.load`.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param context: the :class:`.QueryContext`, which includes
         a handle to the current :class:`.Query` in progress as well
         as additional state information.
        :param row: the result row being handled.  This may be
         an actual :class:`.RowProxy` or may be a dictionary containing
         :class:`.Column` objects as keys.
        :param target: the mapped instance.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :return: When configured with ``retval=True``, a return
         value of ``EXT_STOP`` will bypass instance population by
         the mapper. A value of ``EXT_CONTINUE`` indicates that
         default instance population should take place.

        N(    (   R0   RH   RW   R   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   populate_instance  s    c         C   s   d S(   s
  Receive an object instance before an INSERT statement
        is emitted corresponding to that instance.

        This event is used to modify local, non-object related
        attributes on the instance before an INSERT occurs, as well
        as to emit additional SQL statements on the given
        connection.

        The event is often called for a batch of objects of the
        same class before their INSERT statements are emitted at
        once in a later step. In the extremely rare case that
        this is not desirable, the :func:`.mapper` can be
        configured with ``batch=False``, which will cause
        batches of instances to be broken up into individual
        (and more poorly performing) event->persist->event
        steps.

        .. warning::
            Mapper-level flush events are designed to operate **on attributes
            local to the immediate object being handled
            and via SQL operations with the given**
            :class:`.Connection` **only.** Handlers here should **not** make
            alterations to the state of the :class:`.Session` overall, and
            in general should not affect any :func:`.relationship` -mapped
            attributes, as session cascade rules will not function properly,
            nor is it always known if the related class has already been
            handled. Operations that **are not supported in mapper
            events** include:

            * :meth:`.Session.add`
            * :meth:`.Session.delete`
            * Mapped collection append, add, remove, delete, discard, etc.
            * Mapped relationship attribute set/del events,
              i.e. ``someobject.related = someotherobject``

            Operations which manipulate the state of the object
            relative to other objects are better handled:

            * In the ``__init__()`` method of the mapped object itself, or
              another method designed to establish some particular state.
            * In a ``@validates`` handler, see :ref:`simple_validators`
            * Within the  :meth:`.SessionEvents.before_flush` event.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param connection: the :class:`.Connection` being used to
         emit INSERT statements for this instance.  This
         provides a handle into the current transaction on the
         target database specific to this instance.
        :param target: the mapped instance being persisted.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :return: No return value is supported by this event.

        N(    (   R0   RH   t
   connectionR   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   before_insert.  s    c         C   s   d S(   s
  Receive an object instance after an INSERT statement
        is emitted corresponding to that instance.

        This event is used to modify in-Python-only
        state on the instance after an INSERT occurs, as well
        as to emit additional SQL statements on the given
        connection.

        The event is often called for a batch of objects of the
        same class after their INSERT statements have been
        emitted at once in a previous step. In the extremely
        rare case that this is not desirable, the
        :func:`.mapper` can be configured with ``batch=False``,
        which will cause batches of instances to be broken up
        into individual (and more poorly performing)
        event->persist->event steps.

        .. warning::
            Mapper-level flush events are designed to operate **on attributes
            local to the immediate object being handled
            and via SQL operations with the given**
            :class:`.Connection` **only.** Handlers here should **not** make
            alterations to the state of the :class:`.Session` overall, and in
            general should not affect any :func:`.relationship` -mapped
            attributes, as session cascade rules will not function properly,
            nor is it always known if the related class has already been
            handled. Operations that **are not supported in mapper
            events** include:

            * :meth:`.Session.add`
            * :meth:`.Session.delete`
            * Mapped collection append, add, remove, delete, discard, etc.
            * Mapped relationship attribute set/del events,
              i.e. ``someobject.related = someotherobject``

            Operations which manipulate the state of the object
            relative to other objects are better handled:

            * In the ``__init__()`` method of the mapped object itself,
              or another method designed to establish some particular state.
            * In a ``@validates`` handler, see :ref:`simple_validators`
            * Within the  :meth:`.SessionEvents.before_flush` event.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param connection: the :class:`.Connection` being used to
         emit INSERT statements for this instance.  This
         provides a handle into the current transaction on the
         target database specific to this instance.
        :param target: the mapped instance being persisted.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :return: No return value is supported by this event.

        N(    (   R0   RH   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_inserth  s    c         C   s   d S(   s  Receive an object instance before an UPDATE statement
        is emitted corresponding to that instance.

        This event is used to modify local, non-object related
        attributes on the instance before an UPDATE occurs, as well
        as to emit additional SQL statements on the given
        connection.

        This method is called for all instances that are
        marked as "dirty", *even those which have no net changes
        to their column-based attributes*. An object is marked
        as dirty when any of its column-based attributes have a
        "set attribute" operation called or when any of its
        collections are modified. If, at update time, no
        column-based attributes have any net changes, no UPDATE
        statement will be issued. This means that an instance
        being sent to :meth:`~.MapperEvents.before_update` is
        *not* a guarantee that an UPDATE statement will be
        issued, although you can affect the outcome here by
        modifying attributes so that a net change in value does
        exist.

        To detect if the column-based attributes on the object have net
        changes, and will therefore generate an UPDATE statement, use
        ``object_session(instance).is_modified(instance,
        include_collections=False)``.

        The event is often called for a batch of objects of the
        same class before their UPDATE statements are emitted at
        once in a later step. In the extremely rare case that
        this is not desirable, the :func:`.mapper` can be
        configured with ``batch=False``, which will cause
        batches of instances to be broken up into individual
        (and more poorly performing) event->persist->event
        steps.

        .. warning::
            Mapper-level flush events are designed to operate **on attributes
            local to the immediate object being handled
            and via SQL operations with the given** :class:`.Connection`
            **only.** Handlers here should **not** make alterations to the
            state of the :class:`.Session` overall, and in general should not
            affect any :func:`.relationship` -mapped attributes, as
            session cascade rules will not function properly, nor is it
            always known if the related class has already been handled.
            Operations that **are not supported in mapper events** include:

            * :meth:`.Session.add`
            * :meth:`.Session.delete`
            * Mapped collection append, add, remove, delete, discard, etc.
            * Mapped relationship attribute set/del events,
              i.e. ``someobject.related = someotherobject``

            Operations which manipulate the state of the object
            relative to other objects are better handled:

            * In the ``__init__()`` method of the mapped object itself,
              or another method designed to establish some particular state.
            * In a ``@validates`` handler, see :ref:`simple_validators`
            * Within the  :meth:`.SessionEvents.before_flush` event.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param connection: the :class:`.Connection` being used to
         emit UPDATE statements for this instance.  This
         provides a handle into the current transaction on the
         target database specific to this instance.
        :param target: the mapped instance being persisted.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :return: No return value is supported by this event.
        N(    (   R0   RH   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   before_update  s    c         C   s   d S(   sJ  Receive an object instance after an UPDATE statement
        is emitted corresponding to that instance.

        This event is used to modify in-Python-only
        state on the instance after an UPDATE occurs, as well
        as to emit additional SQL statements on the given
        connection.

        This method is called for all instances that are
        marked as "dirty", *even those which have no net changes
        to their column-based attributes*, and for which
        no UPDATE statement has proceeded. An object is marked
        as dirty when any of its column-based attributes have a
        "set attribute" operation called or when any of its
        collections are modified. If, at update time, no
        column-based attributes have any net changes, no UPDATE
        statement will be issued. This means that an instance
        being sent to :meth:`~.MapperEvents.after_update` is
        *not* a guarantee that an UPDATE statement has been
        issued.

        To detect if the column-based attributes on the object have net
        changes, and therefore resulted in an UPDATE statement, use
        ``object_session(instance).is_modified(instance,
        include_collections=False)``.

        The event is often called for a batch of objects of the
        same class after their UPDATE statements have been emitted at
        once in a previous step. In the extremely rare case that
        this is not desirable, the :func:`.mapper` can be
        configured with ``batch=False``, which will cause
        batches of instances to be broken up into individual
        (and more poorly performing) event->persist->event
        steps.

        .. warning::
            Mapper-level flush events are designed to operate **on attributes
            local to the immediate object being handled
            and via SQL operations with the given** :class:`.Connection`
            **only.** Handlers here should **not** make alterations to the
            state of the :class:`.Session` overall, and in general should not
            affect any :func:`.relationship` -mapped attributes, as
            session cascade rules will not function properly, nor is it
            always known if the related class has already been handled.
            Operations that **are not supported in mapper events** include:

            * :meth:`.Session.add`
            * :meth:`.Session.delete`
            * Mapped collection append, add, remove, delete, discard, etc.
            * Mapped relationship attribute set/del events,
              i.e. ``someobject.related = someotherobject``

            Operations which manipulate the state of the object
            relative to other objects are better handled:

            * In the ``__init__()`` method of the mapped object itself,
              or another method designed to establish some particular state.
            * In a ``@validates`` handler, see :ref:`simple_validators`
            * Within the  :meth:`.SessionEvents.before_flush` event.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param connection: the :class:`.Connection` being used to
         emit UPDATE statements for this instance.  This
         provides a handle into the current transaction on the
         target database specific to this instance.
        :param target: the mapped instance being persisted.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :return: No return value is supported by this event.

        N(    (   R0   RH   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_update  s    c         C   s   d S(   s	  Receive an object instance before a DELETE statement
        is emitted corresponding to that instance.

        This event is used to emit additional SQL statements on
        the given connection as well as to perform application
        specific bookkeeping related to a deletion event.

        The event is often called for a batch of objects of the
        same class before their DELETE statements are emitted at
        once in a later step.

        .. warning::
            Mapper-level flush events are designed to operate **on attributes
            local to the immediate object being handled
            and via SQL operations with the given** :class:`.Connection`
            **only.** Handlers here should **not** make alterations to the
            state of the :class:`.Session` overall, and in general should not
            affect any :func:`.relationship` -mapped attributes, as
            session cascade rules will not function properly, nor is it
            always known if the related class has already been handled.
            Operations that **are not supported in mapper events** include:

            * :meth:`.Session.add`
            * :meth:`.Session.delete`
            * Mapped collection append, add, remove, delete, discard, etc.
            * Mapped relationship attribute set/del events,
              i.e. ``someobject.related = someotherobject``

            Operations which manipulate the state of the object
            relative to other objects are better handled:

            * In the ``__init__()`` method of the mapped object itself,
              or another method designed to establish some particular state.
            * In a ``@validates`` handler, see :ref:`simple_validators`
            * Within the  :meth:`.SessionEvents.before_flush` event.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param connection: the :class:`.Connection` being used to
         emit DELETE statements for this instance.  This
         provides a handle into the current transaction on the
         target database specific to this instance.
        :param target: the mapped instance being deleted.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :return: No return value is supported by this event.

        N(    (   R0   RH   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   before_delete8  s    c         C   s   d S(   s	  Receive an object instance after a DELETE statement
        has been emitted corresponding to that instance.

        This event is used to emit additional SQL statements on
        the given connection as well as to perform application
        specific bookkeeping related to a deletion event.

        The event is often called for a batch of objects of the
        same class after their DELETE statements have been emitted at
        once in a previous step.

        .. warning::
            Mapper-level flush events are designed to operate **on attributes
            local to the immediate object being handled
            and via SQL operations with the given** :class:`.Connection`
            **only.** Handlers here should **not** make alterations to the
            state of the :class:`.Session` overall, and in general should not
            affect any :func:`.relationship` -mapped attributes, as
            session cascade rules will not function properly, nor is it
            always known if the related class has already been handled.
            Operations that **are not supported in mapper events** include:

            * :meth:`.Session.add`
            * :meth:`.Session.delete`
            * Mapped collection append, add, remove, delete, discard, etc.
            * Mapped relationship attribute set/del events,
              i.e. ``someobject.related = someotherobject``

            Operations which manipulate the state of the object
            relative to other objects are better handled:

            * In the ``__init__()`` method of the mapped object itself,
              or another method designed to establish some particular state.
            * In a ``@validates`` handler, see :ref:`simple_validators`
            * Within the  :meth:`.SessionEvents.before_flush` event.

        :param mapper: the :class:`.Mapper` which is the target
         of this event.
        :param connection: the :class:`.Connection` being used to
         emit DELETE statements for this instance.  This
         provides a handle into the current transaction on the
         target database specific to this instance.
        :param target: the mapped instance being deleted.  If
         the event is configured with ``raw=True``, this will
         instead be the :class:`.InstanceState` state-management
         object associated with the instance.
        :return: No return value is supported by this event.

        N(    (   R0   RH   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_deletek  s    (   R5   R6   R7   R8   R   RF   R:   R;   Rx   R   R`   R   Ra   R-   R/   R   R   Ry   Rz   R   R   R   R   R   R   R   R   R   R   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRv     s.   C	'			$	!	#		%	'	:	:	K	K	3Rw   c           B   sH   e  Z e j   Z d    Z d e j e f d     YZ	 e
 j e	  Z RS(   c         C   s
   t  |  S(   N(   R   (   R0   R'   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRl     s    t   HoldMapperEventsc           B   s   e  Z RS(    (   R5   R6   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR     s   (   R5   R6   R&   Ru   Rc   Rl   Rb   Re   Rv   R   R    R>   R   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRw     s   	t   SessionEventsc           B   s   e  Z d  Z d Z e Z e d    Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z e j d d d d d g d    d    Z e j d d d d d g d    d    Z RS(   s  Define events specific to :class:`.Session` lifecycle.

    e.g.::

        from sqlalchemy import event
        from sqlalchemy.orm import sessionmaker

        def my_before_commit(session):
            print "before commit!"

        Session = sessionmaker()

        event.listen(Session, "before_commit", my_before_commit)

    The :func:`~.event.listen` function will accept
    :class:`.Session` objects as well as the return result
    of :class:`~.sessionmaker()` and :class:`~.scoped_session()`.

    Additionally, it accepts the :class:`.Session` class which
    will apply listeners to all :class:`.Session` instances
    globally.

    t   SomeSessionOrFactoryc         C   s   t  | t  r] | j } t  | t  r] t  | t  sH t | t  r] t j d   q] n  t  | t  rs | j	 St  | t  r t | t  r t St | t  r | Sn t  | t  r | Sd  Sd  S(   Nsr   Session event listen on a scoped_session requires that its creation callable is associated with the Session class.(   R   R	   t   session_factoryR   R   R   R   R   t   ArgumentErrorR'   R   (   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR     s"    	c         C   s   d S(   s  Execute when a new :class:`.SessionTransaction` is created.

        This event differs from :meth:`~.SessionEvents.after_begin`
        in that it occurs for each :class:`.SessionTransaction`
        overall, as opposed to when transactions are begun
        on individual database connections.  It is also invoked
        for nested transactions and subtransactions, and is always
        matched by a corresponding
        :meth:`~.SessionEvents.after_transaction_end` event
        (assuming normal operation of the :class:`.Session`).

        :param session: the target :class:`.Session`.
        :param transaction: the target :class:`.SessionTransaction`.

        .. versionadded:: 0.8

        .. seealso::

            :meth:`~.SessionEvents.after_transaction_end`

        N(    (   R0   t   sessiont   transaction(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_transaction_create  s    c         C   s   d S(   s  Execute when the span of a :class:`.SessionTransaction` ends.

        This event differs from :meth:`~.SessionEvents.after_commit`
        in that it corresponds to all :class:`.SessionTransaction`
        objects in use, including those for nested transactions
        and subtransactions, and is always matched by a corresponding
        :meth:`~.SessionEvents.after_transaction_create` event.

        :param session: the target :class:`.Session`.
        :param transaction: the target :class:`.SessionTransaction`.

        .. versionadded:: 0.8

        .. seealso::

            :meth:`~.SessionEvents.after_transaction_create`

        N(    (   R0   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_transaction_end  s    c         C   s   d S(   s!  Execute before commit is called.

        .. note::

            The :meth:`~.SessionEvents.before_commit` hook is *not* per-flush,
            that is, the :class:`.Session` can emit SQL to the database
            many times within the scope of a transaction.
            For interception of these events, use the
            :meth:`~.SessionEvents.before_flush`,
            :meth:`~.SessionEvents.after_flush`, or
            :meth:`~.SessionEvents.after_flush_postexec`
            events.

        :param session: The target :class:`.Session`.

        .. seealso::

            :meth:`~.SessionEvents.after_commit`

            :meth:`~.SessionEvents.after_begin`

            :meth:`~.SessionEvents.after_transaction_create`

            :meth:`~.SessionEvents.after_transaction_end`

        N(    (   R0   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   before_commit  s    c         C   s   d S(   sq  Execute after a commit has occurred.

        .. note::

            The :meth:`~.SessionEvents.after_commit` hook is *not* per-flush,
            that is, the :class:`.Session` can emit SQL to the database
            many times within the scope of a transaction.
            For interception of these events, use the
            :meth:`~.SessionEvents.before_flush`,
            :meth:`~.SessionEvents.after_flush`, or
            :meth:`~.SessionEvents.after_flush_postexec`
            events.

        .. note::

            The :class:`.Session` is not in an active transaction
            when the :meth:`~.SessionEvents.after_commit` event is invoked,
            and therefore can not emit SQL.  To emit SQL corresponding to
            every transaction, use the :meth:`~.SessionEvents.before_commit`
            event.

        :param session: The target :class:`.Session`.

        .. seealso::

            :meth:`~.SessionEvents.before_commit`

            :meth:`~.SessionEvents.after_begin`

            :meth:`~.SessionEvents.after_transaction_create`

            :meth:`~.SessionEvents.after_transaction_end`

        N(    (   R0   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_commit*  s    c         C   s   d S(   s  Execute after a real DBAPI rollback has occurred.

        Note that this event only fires when the *actual* rollback against
        the database occurs - it does *not* fire each time the
        :meth:`.Session.rollback` method is called, if the underlying
        DBAPI transaction has already been rolled back.  In many
        cases, the :class:`.Session` will not be in
        an "active" state during this event, as the current
        transaction is not valid.   To acquire a :class:`.Session`
        which is active after the outermost rollback has proceeded,
        use the :meth:`.SessionEvents.after_soft_rollback` event, checking the
        :attr:`.Session.is_active` flag.

        :param session: The target :class:`.Session`.

        N(    (   R0   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_rollbackN  s    c         C   s   d S(   s  Execute after any rollback has occurred, including "soft"
        rollbacks that don't actually emit at the DBAPI level.

        This corresponds to both nested and outer rollbacks, i.e.
        the innermost rollback that calls the DBAPI's
        rollback() method, as well as the enclosing rollback
        calls that only pop themselves from the transaction stack.

        The given :class:`.Session` can be used to invoke SQL and
        :meth:`.Session.query` operations after an outermost rollback
        by first checking the :attr:`.Session.is_active` flag::

            @event.listens_for(Session, "after_soft_rollback")
            def do_something(session, previous_transaction):
                if session.is_active:
                    session.execute("select * from some_table")

        :param session: The target :class:`.Session`.
        :param previous_transaction: The :class:`.SessionTransaction`
         transactional marker object which was just closed.   The current
         :class:`.SessionTransaction` for the given :class:`.Session` is
         available via the :attr:`.Session.transaction` attribute.

        .. versionadded:: 0.7.3

        N(    (   R0   R   t   previous_transaction(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_soft_rollback`  s    c         C   s   d S(   s  Execute before flush process has started.

        :param session: The target :class:`.Session`.
        :param flush_context: Internal :class:`.UOWTransaction` object
         which handles the details of the flush.
        :param instances: Usually ``None``, this is the collection of
         objects which can be passed to the :meth:`.Session.flush` method
         (note this usage is deprecated).

        .. seealso::

            :meth:`~.SessionEvents.after_flush`

            :meth:`~.SessionEvents.after_flush_postexec`

        N(    (   R0   R   t   flush_contextt	   instances(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   before_flush|  s    c         C   s   d S(   sR  Execute after flush has completed, but before commit has been
        called.

        Note that the session's state is still in pre-flush, i.e. 'new',
        'dirty', and 'deleted' lists still show pre-flush state as well
        as the history settings on instance attributes.

        :param session: The target :class:`.Session`.
        :param flush_context: Internal :class:`.UOWTransaction` object
         which handles the details of the flush.

        .. seealso::

            :meth:`~.SessionEvents.before_flush`

            :meth:`~.SessionEvents.after_flush_postexec`

        N(    (   R0   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_flush  s    c         C   s   d S(   s  Execute after flush has completed, and after the post-exec
        state occurs.

        This will be when the 'new', 'dirty', and 'deleted' lists are in
        their final state.  An actual commit() may or may not have
        occurred, depending on whether or not the flush started its own
        transaction or participated in a larger transaction.

        :param session: The target :class:`.Session`.
        :param flush_context: Internal :class:`.UOWTransaction` object
         which handles the details of the flush.


        .. seealso::

            :meth:`~.SessionEvents.before_flush`

            :meth:`~.SessionEvents.after_flush`

        N(    (   R0   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_flush_postexec  s    c         C   s   d S(   s  Execute after a transaction is begun on a connection

        :param session: The target :class:`.Session`.
        :param transaction: The :class:`.SessionTransaction`.
        :param connection: The :class:`~.engine.Connection` object
         which will be used for SQL statements.

        .. seealso::

            :meth:`~.SessionEvents.before_commit`

            :meth:`~.SessionEvents.after_commit`

            :meth:`~.SessionEvents.after_transaction_create`

            :meth:`~.SessionEvents.after_transaction_end`

        N(    (   R0   R   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_begin  s    c         C   s   d S(   s  Execute before an instance is attached to a session.

        This is called before an add, delete or merge causes
        the object to be part of the session.

        .. versionadded:: 0.8.  Note that :meth:`~.SessionEvents.after_attach`
           now fires off after the item is part of the session.
           :meth:`.before_attach` is provided for those cases where
           the item should not yet be part of the session state.

        .. seealso::

            :meth:`~.SessionEvents.after_attach`

        N(    (   R0   R   t   instance(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   before_attach  s    c         C   s   d S(   s  Execute after an instance is attached to a session.

        This is called after an add, delete or merge.

        .. note::

           As of 0.8, this event fires off *after* the item
           has been fully associated with the session, which is
           different than previous releases.  For event
           handlers that require the object not yet
           be part of session state (such as handlers which
           may autoflush while the target object is not
           yet complete) consider the
           new :meth:`.before_attach` event.

        .. seealso::

            :meth:`~.SessionEvents.before_attach`

        N(    (   R0   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_attach  s    s   0.9R   t   queryt   query_contextR   c         C   s   |  j  |  j |  j |  j f S(   N(   R   R   RW   R   (   t   update_context(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   <lambda>  s    c         C   s   d S(   s  Execute after a bulk update operation to the session.

        This is called as a result of the :meth:`.Query.update` method.

        :param update_context: an "update context" object which contains
         details about the update, including these attributes:

            * ``session`` - the :class:`.Session` involved
            * ``query`` -the :class:`.Query` object that this update operation
              was called upon.
            * ``context`` The :class:`.QueryContext` object, corresponding
              to the invocation of an ORM query.
            * ``result`` the :class:`.ResultProxy` returned as a result of the
              bulk UPDATE operation.


        N(    (   R0   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_bulk_update  s    c         C   s   |  j  |  j |  j |  j f S(   N(   R   R   RW   R   (   t   delete_context(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR     s    c         C   s   d S(   s  Execute after a bulk delete operation to the session.

        This is called as a result of the :meth:`.Query.delete` method.

        :param delete_context: a "delete context" object which contains
         details about the update, including these attributes:

            * ``session`` - the :class:`.Session` involved
            * ``query`` -the :class:`.Query` object that this update operation
              was called upon.
            * ``context`` The :class:`.QueryContext` object, corresponding
              to the invocation of an ORM query.
            * ``result`` the :class:`.ResultProxy` returned as a result of the
              bulk DELETE operation.


        N(    (   R0   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   after_bulk_delete  s    (   R5   R6   R7   R8   R   R:   R;   R   R   R   R   R   R   R   R   R   R   R   R   R   R    t   _legacy_signatureR   R   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR     s,   				$										t   AttributeEventsc           B   sn   e  Z d  Z d Z e Z e d    Z e d    Z	 e e
 e
 e
 e
 d   Z d   Z d   Z d   Z RS(   s  Define events for object attributes.

    These are typically defined on the class-bound descriptor for the
    target class.

    e.g.::

        from sqlalchemy import event

        def my_append_listener(target, value, initiator):
            print "received append event for target: %s" % target

        event.listen(MyClass.collection, 'append', my_append_listener)

    Listeners have the option to return a possibly modified version
    of the value, when the ``retval=True`` flag is passed
    to :func:`~.event.listen`::

        def validate_phone(target, value, oldvalue, initiator):
            "Strip non-numeric characters from a phone number"

            return re.sub(r'(?![0-9])', '', value)

        # setup listener on UserContact.phone attribute, instructing
        # it to use the return value
        listen(UserContact.phone, 'set', validate_phone, retval=True)

    A validation function like the above can also raise an exception
    such as :exc:`ValueError` to halt the operation.

    Several modifiers are available to the :func:`~.event.listen` function.

    :param active_history=False: When True, indicates that the
      "set" event would like to receive the "old" value being
      replaced unconditionally, even if this requires firing off
      database loads. Note that ``active_history`` can also be
      set directly via :func:`.column_property` and
      :func:`.relationship`.

    :param propagate=False: When True, the listener function will
      be established not just for the class attribute given, but
      for attributes of the same name on all current subclasses
      of that class, as well as all future subclasses of that
      class, using an additional listener that listens for
      instrumentation events.
    :param raw=False: When True, the "target" argument to the
      event will be the :class:`.InstanceState` management
      object, rather than the mapped instance itself.
    :param retval=False: when True, the user-defined event
      listening must return the "value" argument from the
      function.  This gives the listening function the opportunity
      to change the value that is ultimately used for a "set"
      or "append" event.

    s   SomeClass.some_attributec         C   s    t  j j |  |  t | _ d  S(   N(   R    t   Eventst   _set_dispatchRa   t   _active_history(   R   t   dispatch_cls(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR   d  s    c         C   s0   t  | t j  r( t | j j | j  S| Sd  S(   N(   R   R   t   MapperPropertyR   t   parentR'   R"   (   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR   i  s    c            s   | j  | j | j } }  | r2 t | j _ n    s@  rg     f d   } | j |  } n  | j d |  | r t j	 | j
  }	 x: |	 j t  D]& }
 | j |
 | j  j d t  q Wn  d  S(   Nc            sC     s |  j    }  n   s/  |  | |  | S |  | |  Sd  S(   N(   RL   (   R   t   valueR   (   RP   R}   R   (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyRN   ~  s    R   (   R$   R#   R%   R<   R   R   R)   R*   R   RI   R'   RO   R(   R"   (   R   R+   t   active_historyRP   R}   R   R   R#   RN   RK   RQ   (    (   RP   R}   R   s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR-   q  s    c         C   s   d S(   s)  Receive a collection append event.

        :param target: the object instance receiving the event.
          If the listener is registered with ``raw=True``, this will
          be the :class:`.InstanceState` object.
        :param value: the value being appended.  If this listener
          is registered with ``retval=True``, the listener
          function must return this value, or a new value which
          replaces it.
        :param initiator: An instance of :class:`.attributes.Event`
          representing the initiation of the event.  May be modified
          from its original value by backref handlers in order to control
          chained event propagation.

          .. versionchanged:: 0.9.0 the ``initiator`` argument is now
             passed as a :class:`.attributes.Event` object, and may be
             modified by backref handlers within a chain of backref-linked
             events.

        :return: if the event was registered with ``retval=True``,
         the given value, or a new effective value, should be returned.

        N(    (   R0   R   R   t	   initiator(    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   append  s    c         C   s   d S(   s4  Receive a collection remove event.

        :param target: the object instance receiving the event.
          If the listener is registered with ``raw=True``, this will
          be the :class:`.InstanceState` object.
        :param value: the value being removed.
        :param initiator: An instance of :class:`.attributes.Event`
          representing the initiation of the event.  May be modified
          from its original value by backref handlers in order to control
          chained event propagation.

          .. versionchanged:: 0.9.0 the ``initiator`` argument is now
             passed as a :class:`.attributes.Event` object, and may be
             modified by backref handlers within a chain of backref-linked
             events.

        :return: No return value is defined for this event.
        N(    (   R0   R   R   R   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR      s    c         C   s   d S(   s  Receive a scalar set event.

        :param target: the object instance receiving the event.
          If the listener is registered with ``raw=True``, this will
          be the :class:`.InstanceState` object.
        :param value: the value being set.  If this listener
          is registered with ``retval=True``, the listener
          function must return this value, or a new value which
          replaces it.
        :param oldvalue: the previous value being replaced.  This
          may also be the symbol ``NEVER_SET`` or ``NO_VALUE``.
          If the listener is registered with ``active_history=True``,
          the previous value of the attribute will be loaded from
          the database if the existing value is currently unloaded
          or expired.
        :param initiator: An instance of :class:`.attributes.Event`
          representing the initiation of the event.  May be modified
          from its original value by backref handlers in order to control
          chained event propagation.

          .. versionchanged:: 0.9.0 the ``initiator`` argument is now
             passed as a :class:`.attributes.Event` object, and may be
             modified by backref handlers within a chain of backref-linked
             events.

        :return: if the event was registered with ``retval=True``,
         the given value, or a new effective value, should be returned.

        N(    (   R0   R   R   t   oldvalueR   (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   set  s    (   R5   R6   R7   R8   R
   R:   t   staticmethodR   R;   R   Ra   R-   R   R    R   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyR   (  s   7		(   R7   t    R    R   R   t   baseR   R   R&   R   R   R   R   R   R   t   scopingR	   t
   attributesR
   R   R   Rs   R   R?   t   RefCollectionRb   RA   Rv   Rw   R   R   (    (    (    s[   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/orm/events.pyt   <module>
   s*   ZC   ~