Repository URL to install this package:
Version:
4.0.109 ▾
|
ó EYc @@ 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( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/event/api.pyt _event_key s c O@ s t | | | j | | d S( sL 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`. .. note:: The :func:`.listen` function cannot be called at the same time that the target event is being run. This has implications for thread safety, and also means an event cannot be added from inside the listener function for itself. The list of events to be run are present inside of a mutable collection that can't be changed during iteration. Event registration and removal is not intended to be a "high velocity" operation; it is a configurational operation. For systems that need to quickly associate and deassociate with events at high scale, use a mutable structure that is handled from inside of a single listener. .. versionchanged:: 1.0.0 - a ``collections.deque()`` object is now used as the container for the list of events, which explicitly disallows collection mutation while the collection is being iterated. .. seealso:: :func:`.listens_for` :func:`.remove` N( R t listen( R R R t argst kw( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/event/api.pyR s :c @ s f d } | S( sY 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`. .. seealso:: :func:`.listen` - general description of event listening c @ s t | | S( N( R ( R ( R R R R ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/event/api.pyt decorate{ s ( ( R R R R R ( ( R R R R sI /home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/event/api.pyt listens_for\ 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 .. note:: The :func:`.remove` function cannot be called at the same time that the target event is being run. This has implications for thread safety, and also means an event cannot be removed from inside the listener function for itself. The list of events to be run are present inside of a mutable collection that can't be changed during iteration. Event registration and removal is not intended to be a "high velocity" operation; it is a configurational operation. For systems that need to quickly associate and deassociate with events at high scale, use a mutable structure that is handled from inside of a single listener. .. versionchanged:: 1.0.0 - a ``collections.deque()`` object is now used as the container for the list of events, which explicitly disallows collection mutation while the collection is being iterated. .. seealso:: :func:`.listen` N( R t remove( R R R ( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/event/api.pyR s 1c 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 ( ( sI /home/tvault/.virtenv/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 ( ( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/event/api.pyt <module> s = % 4