4,Q@dZddlZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd l mZdd l mZdd l mZdd l mZddl mZdZ dZegZ GddeZexe _Zee _GddeZGddeZdZdZdZdS)aExtensible 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`. N)util) attributes)base) collections)exc)instrumentation)_default_dict_getter)_default_manager_getter)_default_state_getter) ClassManager)InstrumentationFactory__sa_instrumentation_manager__c.t|tdS)z;Find user-specified instrumentation management for a class.N)getattrINSTRUMENTATION_MANAGERclss /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/sqlalchemy/ext/instrumentation.py%find_native_user_instrumentation_hookr;s 3/ 6 66ceZdZdZejZejZejZdZ dZ dZ dZ dZ fdZdZd Zd ZxZS) ExtendedInstrumentationRegistryzExtends :class:`.InstrumentationFactory` with additional bookkeeping, to accommodate multiple types of class managers. FcltD]+}||}||||}||fcS,dS)N)NN)instrumentation_finders_extended_class_manager)selfclass_finderfactorymanagers r_locate_extended_factoryz8ExtendedInstrumentationRegistry._locate_extended_factory]sV-  FfVnnG"66vwGG''''#:rc|||g}|r'td|jdt |dS)Nz6multiple instrumentation implementations specified in z inheritance hierarchy: )!_collect_management_factories_for difference TypeError__name__list)rrr existing_factoriess r_check_conflictsz0ExtendedInstrumentationRegistry._check_conflictsfsr!CC   *gY     )???D);$<$<$<>   rc\||}t|tst||}|tkr|jsd|_t ||j|<||j|<| |j |<|S)NT) isinstancer _ClassInstrumentationAdapter _extended_install_instrumented_lookupsmanager_getter_manager_finders state_getter_state_finders dict_getter _dict_finders)rrr r!s rrz7ExtendedInstrumentationRegistry._extended_class_managerqs'&//'<00 D267CCG l " "4> ""DN ) + + +(/(>(>(@(@f%&-&:&:&<&<F#%,%8%8%:%:6"rcBtj|}t}|D]d}||}|||j4t D]}||}|nd}||e|d|S)acReturn 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)rclass_hierarchysetmanager_of_classaddr rdiscard)rr hierarchy factoriesmemberr!rr s rr$zAExtendedInstrumentationRegistry._collect_management_factories_fors(-- EE  ' 'F++F33G" go....5##F$fVnnG*+#G g&&&&$rc||jvr|j|=|j|=|j|=tt||dSN)r1r3r5superr unregister)rr __class__s rrBz*ExtendedInstrumentationRegistry.unregistersW T* * *%f-#F+"6* -t44??GGGGGrc|dS |j|t}||S#t$rYdSwxYwr@)r1getr r&)rrrs rr9z0ExtendedInstrumentationRegistry.manager_of_classs^ ;4 *..s4KLLF 6#;;     44 s 1 ??c|td|j|jt|SNzNone has no persistent state.)AttributeErrorr3rErCr rinstances rstate_ofz(ExtendedInstrumentationRegistry.state_ofsL   !@AA A t"&&   5   rc|td|j|jt|SrG)rHr5rErCr rIs rdict_ofz'ExtendedInstrumentationRegistry.dict_ofsL   !@AA A t!%%   4   r)r' __module__ __qualname____doc__weakrefWeakKeyDictionaryr1r3r5r.r"r*rr$rBr9rKrM __classcell__rCs@rrrQs 1w022.W.00N-G-//MI   "6HHHHH   rrcxeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdS)InstrumentationManageraWUser-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. cdSr@rrs r__init__zInstrumentationManager.__init__ rc(t|d|dSN_default_class_managersetattrrrr!s rmanagezInstrumentationManager.manages0':::::rc&t|ddSr]delattrras rdisposezInstrumentationManager.disposes011111rc d}|S)Nc|jSr@)r^rs rrEz2InstrumentationManager.manager_getter..gets - -rrX)rrrEs rr0z%InstrumentationManager.manager_getters . . . rcdSr@rXrrkeyinsts rinstrument_attributez+InstrumentationManager.instrument_attributer[rcdSr@rXrjs rpost_configure_attributez/InstrumentationManager.post_configure_attributer[rc(t|||dSr@r_rjs rinstall_descriptorz)InstrumentationManager.install_descriptorsT"""""rc&t||dSr@rdrrrks runinstall_descriptorz+InstrumentationManager.uninstall_descriptorrc(t|||dSr@r_)rrrkimplementations rinstall_memberz%InstrumentationManager.install_members^,,,,,rc&t||dSr@rdrss runinstall_memberz'InstrumentationManager.uninstall_memberrurc*tj|Sr@)rprepare_instrumentation)rrrkcollection_classs rinstrument_collection_classz2InstrumentationManager.instrument_collection_classs23CDDDrc|jSr@)__dict__rrrJs rget_instance_dictz(InstrumentationManager.get_instance_dicts   rcdSr@rXrs rinitialize_instance_dictz/InstrumentationManager.initialize_instance_dictr[rc(t|d|dSN_default_stater_)rrrJstates r install_statez$InstrumentationManager.install_states*E22222rc&t|ddSrrdrs r remove_statez#InstrumentationManager.remove_states*+++++rcdS)Nc"t|dSr)r)rJs rz5InstrumentationManager.state_getter.. s2B C CrrXrYs rr2z#InstrumentationManager.state_getter s CCCrcfdS)Nc0|Sr@)r)rlrrs rrz4InstrumentationManager.dict_getter.. sD2264@@rrXrYs``rr4z"InstrumentationManager.dict_getter s@@@@@@rN)r'rNrOrPrZrbrfr0rmrorqrtrxrzr~rrrrr2r4rXrrrVrVs((   ;;;222       ###---EEE!!!   333,,,DDDAAAAArrVceZdZdZdZdZdZdZddZfdZ d Z d Z d Z d Z d ZdZddZdZddZdZdZdZdZxZS)r-z?Adapts a user-defined InstrumentationManager to a ClassManager.c||_|j||_|j||_t j||dSr@)_adaptedr2 _get_stater4 _get_dictr rZ)rroverrides rrZz%_ClassInstrumentationAdapter.__init__sP  -44V<<226::dF+++++rcF|j|j|dSr@)rrbrrs rrbz#_ClassInstrumentationAdapter.manages" T[$/////rcD|j|jdSr@)rrfrrs rrfz$_ClassInstrumentationAdapter.disposes  dk*****rc@|j|jSr@)rr0rrs rr0z+_ClassInstrumentationAdapter.manager_getter s}++DK888rFc~tj|||||s#|j|j||dSdSr@)r rmrr)rrkrl propagateds rrmz1_ClassInstrumentationAdapter.instrument_attribute#sP)$T:FFF G M . .t{C F F F F F G Grctt|||j|j|||dSr@)rAr-rorr)rrkrCs rroz5_ClassInstrumentationAdapter.post_configure_attribute(sH *D11JJ3OOO ..t{CcKKKKKrcH|j|j||dSr@)rrqr)rrkrls rrqz/_ClassInstrumentationAdapter.install_descriptor,s$ ((c4@@@@@rcF|j|j|dSr@)rrtrrrks rrtz1_ClassInstrumentationAdapter.uninstall_descriptor/s" **4;<<<<>( # # 15&&x00 0rc|j|j|||||}|j|j|||Sr@)rrr_state_constructorr)rrJrs rrz+_ClassInstrumentationAdapter.setup_instanceUsY ..t{HEEE =++Hd;;E ##DK5AAA rcF|j|j|dSr@)rrrrIs rteardown_instancez._ClassInstrumentationAdapter.teardown_instance_s" ""4;99999rc^ ||dS#tj$rYdSwxYw)NTF)rorm_excNO_STATErIs rrz&_ClassInstrumentationAdapter.has_statebsG  OOH % % %4   55 s ,,c|jSr@)rrs rr2z)_ClassInstrumentationAdapter.state_getterjs rc|jSr@)rrs rr4z(_ClassInstrumentationAdapter.dict_getterms ~r)Fr@)r'rNrOrPrZrbrfr0rmrorqrtrxrzr~rrrrrrr2r4rSrTs@rr-r-sjII,,,000+++999GGGG LLLLLAAA===GGG999    111:::rr-ctttjtjtjdS)aReplace 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. instance_state instance_dictr9N)_install_lookupsdict_instrumentation_factoryrKrMr9rXrrr/r/qsD 3<2:5F   rcztttttdt _dS)zRestore simplified lookups.rFN)rrr r r rr.rXrr_reinstall_default_lookupsrs@ 0.4   */&&&rc,|da|da|datxt_xt_t _txt_xt_t _txt_xt_t _dS)Nrrr9)rrr9orm_baserorm_instrumentation)lookupss rrrs-.NO,M12.<rs""""""" 888888666666999999777777......888888;2777 AA  jjjjj&<jjj^$#%%&,.E+IAIAIAIAIAVIAIAIAX^^^^^<^^^B, / / / @ @ @ @ @r