ó
H`¾Tc           @@  s›   d  Z  d d l m Z d d l m Z m Z d d l m Z d d l m	 Z	 e j
 d ƒ Z e j
 d	 ƒ Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d S(   s,   Public API functions for the event system.

i    (   t   absolute_importi   (   t   utilt   exci   (   t   _registrars(   t	   _EventKeyt   CANCELt	   NO_RETVALc         C@  s`   xY t  | D]4 } | j |  ƒ } | d  k	 r t |  | | | ƒ Sq Wt j d | |  f ƒ ‚ d  S(   Ns"   No such event '%s' for target '%s'(   R   t   _accept_witht   NoneR   R   t   InvalidRequestError(   t   targett
   identifiert   fnt   evt_clst   tgt(    (    sZ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/event/api.pyt
   _event_key   s    	c         O@  s    t  |  | | ƒ j | | Ž  d S(   s<  Register a listener function for the given target.

    e.g.::

        from sqlalchemy import event
        from sqlalchemy.schema import UniqueConstraint

        def unique_constraint_name(const, table):
            const.name = "uq_%s_%s" % (
                table.name,
                list(const.columns)[0].name
            )
        event.listen(
                UniqueConstraint,
                "after_parent_attach",
                unique_constraint_name)


    A given function can also be invoked for only the first invocation
    of the event using the ``once`` argument::

        def on_config():
            do_config()

        event.listen(Mapper, "before_configure", on_config, once=True)

    .. versionadded:: 0.9.4 Added ``once=True`` to :func:`.event.listen`
       and :func:`.event.listens_for`.

    N(   R   t   listen(   R
   R   R   t   argst   kw(    (    sZ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/event/api.pyR      s     c         @  s   ‡ ‡ ‡ ‡  f d †  } | S(   s  Decorate a function as a listener for the given target + identifier.

    e.g.::

        from sqlalchemy import event
        from sqlalchemy.schema import UniqueConstraint

        @event.listens_for(UniqueConstraint, "after_parent_attach")
        def unique_constraint_name(const, table):
            const.name = "uq_%s_%s" % (
                table.name,
                list(const.columns)[0].name
            )

    A given function can also be invoked for only the first invocation
    of the event using the ``once`` argument::

        @event.listens_for(Mapper, "before_configure", once=True)
        def on_config():
            do_config()


    .. versionadded:: 0.9.4 Added ``once=True`` to :func:`.event.listen`
       and :func:`.event.listens_for`.

    c         @  s   t  ˆ  ˆ |  ˆ ˆ Ž |  S(   N(   R   (   R   (   R
   R   R   R   (    sZ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/event/api.pyt   decorate]   s    (    (   R
   R   R   R   R   (    (   R   R   R
   R   sZ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/event/api.pyt   listens_forB   s    c         C@  s   t  |  | | ƒ j ƒ  d S(   s,  Remove an event listener.

    The arguments here should match exactly those which were sent to
    :func:`.listen`; all the event registration which proceeded as a result
    of this call will be reverted by calling :func:`.remove` with the same
    arguments.

    e.g.::

        # if a function was registered like this...
        @event.listens_for(SomeMappedClass, "before_insert", propagate=True)
        def my_listener_function(*arg):
            pass

        # ... it's removed like this
        event.remove(SomeMappedClass, "before_insert", my_listener_function)

    Above, the listener function associated with ``SomeMappedClass`` was also
    propagated to subclasses of ``SomeMappedClass``; the :func:`.remove`
    function will revert all of these operations.

    .. versionadded:: 0.9.0

    N(   R   t   remove(   R
   R   R   (    (    sZ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/event/api.pyR   c   s    c         C@  s   t  |  | | ƒ j ƒ  S(   s`   Return True if the given target/ident/fn is set up to listen.

    .. versionadded:: 0.9.0

    (   R   t   contains(   R
   R   R   (    (    sZ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/event/api.pyR      s    N(   t   __doc__t
   __future__R    t    R   R   t   baseR   t   registryR   t   symbolR   R   R   R   R   R   R   (    (    (    sZ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/event/api.pyt   <module>
   s   	
	#	!	