ó ÃÌ4]c@sTdZddlZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd l mZdd l mZdd l mZdd l mZddl mZdZd„ZegZdefd„ƒYZeƒe _Zee _defd„ƒYZdefd„ƒYZd„Zd„Zd„ZdS(sExtensible class instrumentation. The :mod:`sqlalchemy.ext.instrumentation` package provides for alternate systems of class instrumentation within the ORM. Class instrumentation refers to how the ORM places attributes on the class which maintain data and track changes to that data, as well as event hooks installed on the class. .. note:: The extension package is provided for the benefit of integration with other object management packages, which already perform their own instrumentation. It is not intended for general use. For examples of how the instrumentation extension is used, see the example :ref:`examples_instrumentation`. iÿÿÿÿNi(tutil(t attributes(tbase(t collections(texc(tinstrumentation(t_default_dict_getter(t_default_manager_getter(t_default_state_getter(t ClassManager(tInstrumentationFactoryt__sa_instrumentation_manager__cCst|tdƒS(s;Find user-specified instrumentation management for a class.N(tgetattrtINSTRUMENTATION_MANAGERtNone(tcls((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt%find_native_user_instrumentation_hook;stExtendedInstrumentationRegistrycBs€eZdZejƒZejƒZejƒZeZ d„Z d„Z d„Z d„Z d„Zd„Zd„Zd„ZRS( s„Extends :class:`.InstrumentationFactory` with additional bookkeeping, to accommodate multiple types of class managers. cCsMxFtD]:}||ƒ}|dk r|j||ƒ}||fSqWdSdS(N(NN(tinstrumentation_findersRt_extended_class_manager(tselftclass_tfindertfactorytmanager((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt_locate_extended_factory]s    cCsG|j|ƒj|gƒ}|rCtd|jt|ƒfƒ‚ndS(NsRmultiple instrumentation implementations specified in %s inheritance hierarchy: %r(t!_collect_management_factories_fort differencet TypeErrort__name__tlist(RRRtexisting_factories((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt_check_conflictsfs  cCs“||ƒ}t|tƒs-t||ƒ}n|tkrV|j rVt|_tƒn|jƒ|j|<|jƒ|j |<|j ƒ|j |<|S(N( t isinstanceR t_ClassInstrumentationAdaptert _extendedtTruet_install_instrumented_lookupstmanager_gettert_manager_finderst state_gettert_state_finderst dict_gettert _dict_finders(RRRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRqs   cCs¨tj|ƒ}tƒ}x||D]t}|j|ƒ}|dk rS|j|jƒqx0tD]"}||ƒ}|dk rZPqZqZWd}|j|ƒqW|jdƒ|S(scReturn a collection of factories in play or specified for a hierarchy. Traverses the entire inheritance graph of a cls and returns a collection of instrumentation factories for those classes. Factories are extracted from active ClassManagers, if available, otherwise instrumentation_finders is consulted. N( Rtclass_hierarchytsettmanager_of_classRtaddRRtdiscard(RRt hierarchyt factoriestmemberRRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR‚s        cCsJ||jkr0|j|=|j|=|j|=ntt|ƒj|ƒdS(N(R'R)R+tsuperRt unregister(RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR5s    cCsL|dkrdSy|jj|tƒ}Wntk r=dSX||ƒSdS(N(RR'tgetRR(RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR.¤s  cCs7|dkrtdƒ‚n|jj|jtƒ|ƒS(NsNone has no persistent state.(RtAttributeErrorR)R6t __class__R(Rtinstance((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytstate_of¯s    cCs7|dkrtdƒ‚n|jj|jtƒ|ƒS(NsNone has no persistent state.(RR7R+R6R8R(RR9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytdict_of¶s    (Rt __module__t__doc__tweakreftWeakKeyDictionaryR'R)R+tFalseR#RR RRR5R.R:R;(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRQs       tInstrumentationManagercBs§eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„ZRS(sWUser-defined class instrumentation extension. :class:`.InstrumentationManager` can be subclassed in order to change how class instrumentation proceeds. This class exists for the purposes of integration with other object management frameworks which would like to entirely modify the instrumentation methodology of the ORM, and is not intended for regular usage. For interception of class instrumentation events, see :class:`.InstrumentationEvents`. The API for this class should be considered as semi-stable, and may change slightly with new releases. cCsdS(N((RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt__init__ÙscCst|d|ƒdS(Nt_default_class_manager(tsetattr(RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytmanageÜscCst|dƒdS(NRC(tdelattr(RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytdisposeßscCs d„}|S(NcSs|jS(N(RC(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR6ãs((RRR6((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR&âs cCsdS(N((RRtkeytinst((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytinstrument_attributeèscCsdS(N((RRRHRI((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytpost_configure_attributeëscCst|||ƒdS(N(RD(RRRHRI((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytinstall_descriptorîscCst||ƒdS(N(RF(RRRH((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytuninstall_descriptorñscCst|||ƒdS(N(RD(RRRHtimplementation((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytinstall_memberôscCst||ƒdS(N(RF(RRRH((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytuninstall_member÷scCs tj|ƒS(N(Rtprepare_instrumentation(RRRHtcollection_class((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytinstrument_collection_classúscCs|jS(N(t__dict__(RRR9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytget_instance_dictýscCsdS(N((RRR9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytinitialize_instance_dictscCst|d|ƒdS(Nt_default_state(RD(RRR9tstate((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt install_statescCst|dƒdS(NRW(RF(RRR9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt remove_statescCsd„S(NcSs t|dƒS(NRW(R (R9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt t((RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR( scs‡‡fd†S(Ncsˆjˆ|ƒS(N(RU(RI(RR(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR[ R\((RR((RRsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR* s(RR<R=RBRERGR&RJRKRLRMRORPRSRURVRYRZR(R*(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRAÄs$                R"cBsÂeZdZd„Zd„Zd„Zd„Zed„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zdd „Zd„Zdd„Zd„Zd„Zd„Zd„ZRS(s?Adapts a user-defined InstrumentationManager to a ClassManager.cCsG||_|jj|ƒ|_|jj|ƒ|_tj||ƒdS(N(t_adaptedR(t _get_stateR*t _get_dictR RB(RRtoverride((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRBs cCs|jj|j|ƒdS(N(R]RER(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyREscCs|jj|jƒdS(N(R]RGR(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRGscCs|jj|jƒS(N(R]R&R(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR& scCs<tj||||ƒ|s8|jj|j||ƒndS(N(R RJR]R(RRHRIt propagated((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRJ#scCs7tt|ƒj|ƒ|jj|j|||ƒdS(N(R4R"RKR]R(RRH((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRK(scCs|jj|j||ƒdS(N(R]RLR(RRHRI((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRL,scCs|jj|j|ƒdS(N(R]RMR(RRH((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRM/scCs|jj|j||ƒdS(N(R]ROR(RRHRN((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRO2scCs|jj|j|ƒdS(N(R]RPR(RRH((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRP5scCs|jj|j||ƒS(N(R]RSR(RRHRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRS8s cCsEt|jddƒ}|r+||||ƒStj||||ƒSdS(Ntinitialize_collection(R R]RR Rb(RRHRXRtdelegate((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRb=s cCs)|jj|jƒ}|j||ƒ|S(N(Rt__new__tsetup_instance(RRXR9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt new_instanceFscCs$|j|ƒrtS|j|ƒSdS(s‚Install a default InstanceState if none is present. A private convenience method used by the __init__ decorator. N(t has_stateR@Re(RR9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt_new_state_if_noneKscCsT|jj|j|ƒ|dkr7|j||ƒ}n|jj|j||ƒ|S(N(R]RVRRt_state_constructorRY(RR9RX((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyReUs  cCs|jj|j|ƒdS(N(R]RZR(RR9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pytteardown_instance_scCs1y|j|ƒWntjk r(tSXtSdS(N(R^torm_exctNO_STATER@R$(RR9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRgbs cCs|jS(N(R^(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR(jscCs|jS(N(R_(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR*msN(RR<R=RBRERGR&R@RJRKRLRMRORPRSRbRRfRhReRjRgR(R*(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR"s(               cCs,ttdtjdtjdtjƒƒdS(sºReplace global class/object management functions with ExtendedInstrumentationRegistry implementations, which allow multiple types of class managers to be present, at the cost of performance. This function is called only by ExtendedInstrumentationRegistry and unit tests specific to this behavior. The _reinstall_default_lookups() function can be called after this one to re-establish the default functions. tinstance_statet instance_dictR.N(t_install_lookupstdictt_instrumentation_factoryR:R;R.(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyR%qs   cCs,ttdtdtdtƒƒtt_dS(sRestore simplified lookups.RmRnR.N(RoRpRRRR@RqR#(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyt_reinstall_default_lookups‡s  cCsg|da|da|datt_t_t_tt_t_t_tt_t_t_dS(NRmRnR.(RmRnR.torm_baseRtorm_instrumentation(tlookups((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyRo“s    (R=R>R\RtormRRRsRRRkRRttorm.instrumentationRRRR R R RRRRqtobjectRAR"R%RrRo(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/instrumentation.pyts.   o La