ó ÃÌ4]c@ÀsUdZddlmZddlmZddlZddlmZddlZddlm Z ddlm Z d d lm Z d d lm Z d d l m Z d e jfd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(s•Attribute implementation for _Dispatch classes. The various listener targets for a particular event class are represented as attributes, which refer to collections of listeners to be fired off. These collections can exist at the class level as well as at the instance level. An event is fired off using code like this:: some_object.dispatch.first_connect(arg1, arg2) Above, ``some_object.dispatch`` would be an instance of ``_Dispatch`` and ``first_connect`` is typically an instance of ``_ListenerCollection`` if event listeners are present, or ``_EmptyListener`` if none are present. The attribute mechanics here spend effort trying to ensure listener functions are available with a minimum of function call overhead, that unnecessary objects aren't created (i.e. many empty per-instance listener collections), as well as that everything is garbage collectable when owning references are lost. Other features such as "propagation" of listener functions across many ``_Dispatch`` instances, "joining" of multiple ``_Dispatch`` instances, as well as support for subclass propagation (e.g. events assigned to ``Pool`` vs. ``QueuePool``) are all implemented here. i(tabsolute_import(twith_statementN(tchaini(tlegacy(tregistryi(texc(tutil(t threadingt RefCollectioncBÀseZdZd„ZRS(trefcCÀstj|tjƒS(N(tweakrefR Rt_collection_gced(tself((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pyt_memoized_attr_ref1s(R (t__name__t __module__t __slots__R (((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pyR.st_empty_collectioncBÀs5eZd„Zd„Zd„Zd„Zd„ZRS(cCÀsdS(N((R telement((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pytappend6scCÀsdS(N((R tother((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pytextend9scCÀsdS(N((R R((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pytremove<scCÀs tgƒS(N(titer(R ((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pyt__iter__?scCÀsdS(N((R ((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pytclearBs(RRRRRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pyR5s     t_ClsLevelDispatchcBÀsneZdZdZd„Zd„Zd „Zd „Zd „Zd „Z d „Z d„Z d„Z d„Z RS(s2Class-level events on :class:`._Dispatch` classes.tnamet arg_namesthas_kwtlegacy_signaturest _clslevelt __weakref__cCÀs˜|j|_tj|ƒ}|jd|_t|jƒ|_t t t t |dgƒdd„ƒƒƒ|_ tj|||ƒ|_tjƒ|_dS(Nit_legacy_signaturestkeycSÀs|dS(Ni((ts((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pytZt(RRRtinspect_getfullargspectargsRtbooltvarkwRtlisttreversedtsortedtgetattrRRt_augment_fn_docst__doc__R tWeakKeyDictionaryR(R tparent_dispatch_clstfntargspec((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pyt__init__Rs 'cCÀsj|r|j|ƒ}n|jrfytj|dtƒ}Wntk rMqfXtj|||ƒ}n|S(Ntno_self(t_wrap_fn_for_kwRRtget_callable_argspectTruet TypeErrorRt_wrap_fn_for_legacy(R R2tnamedR3((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pyt_adjust_fn_specbs  cÀs‡‡fd†}|S(NcÀs/ttˆj|ƒƒ}|j|ƒˆ|S(N(tdicttzipRtupdate(R'tkwtargdict(R2R (sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pytwrap_kwos ((R R2RB((R2R sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pyR6nscCÀsÞ|j}t|dtƒs1tjd|ƒ‚n|g}x|rÉ|jdƒ}|j|jƒƒ||k r||jkr|j |ƒq=||jkr¯|j |ƒn|j|j |j ƒq=Wt j||ƒdS(Nt_sa_propagate_class_eventss.Can't assign an event directly to the %s classi(tdispatch_targetR-R8RtInvalidRequestErrortpopRt__subclasses__Rtupdate_subclasst_assign_cls_collectiont appendleftt _listen_fnRt_stored_in_collection(R t event_keyt propagatettargettstacktcls((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pytinsertvs   cCÀsÞ|j}t|dtƒs1tjd|ƒ‚n|g}x|rÉ|jdƒ}|j|jƒƒ||k r||jkr|j |ƒq=||jkr¯|j |ƒn|j|j |j ƒq=Wt j||ƒdS(NRCs.Can't assign an event directly to the %s classi(RDR-R8RRERFRRGRRHRIRRKRRL(R RMRNRORPRQ((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/event/attr.pyR‹s   cCÀs<t|dtƒr(tjƒ|j|s$  ‡=&O