Files
aitsc/.venv/Lib/site-packages/sqlalchemy/ext/__pycache__/instrumentation.cpython-312.pyc

111 lines
19 KiB
Plaintext
Raw Normal View History

2025-02-23 09:07:52 +08:00
<EFBFBD>
2025-08-29 00:34:40 +08:00
<00><19>h?<00><00><<00>dZddlZddlmZddlmZddlmZddlmZddlm Z
2025-02-23 09:07:52 +08:00
dd lm Z ddlmZ dd
lmZdd lmZdd lmZdd lmZddlmZddlmZdZ d<11>ZegZ Gd<12>de<14>Ze<18>xe _Zee _Gd<14>d<15>ZGd<16>de<13>Zd<18>Zd<19>Zd<1A>Zy)a<>Extensible 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`.
<EFBFBD>N<>)<01>util)<01>
2025-08-29 00:34:40 +08:00
attributes)<01>base)<01> collections)<01>exc)<01>instrumentation)<01>_default_dict_getter)<01>_default_manager_getter)<01>_default_opt_manager_getter)<01>_default_state_getter)<01> ClassManager)<01>InstrumentationFactory<72>__sa_instrumentation_manager__c<00>$<00>t|td<01>S)z;Find user-specified instrumentation management for a class.N)<02>getattr<74>INSTRUMENTATION_MANAGER<45><01>clss <20>KD:\pythonpj\aitsc\.venv\Lib\site-packages\sqlalchemy/ext/instrumentation.py<70>%find_native_user_instrumentation_hookrEs<00><00> <12>3<EFBFBD>/<2F><14> 6<>6<>c<00><><00><00>eZdZdZej
2025-02-23 09:07:52 +08:00
<00>Zej
<00>Zej
<00>ZdZ d<03>Z
d<04>Z d<05>Z d<06>Z <0A>fd<07>Zd<08>Zd <09>Zd
<EFBFBD>Zd <0B>Z<12>xZS) <0C>ExtendedInstrumentationRegistryz<79>Extends :class:`.InstrumentationFactory` with additional
bookkeeping, to accommodate multiple types of
class managers.
Fc<00>^<00>tD]$}||<01>}|<03><01>|j||<03>}||fcSy)N)NN)<02>instrumentation_finders<72>_extended_class_manager)<05>self<6C>class_<73>finder<65>factory<72>managers r<00>_locate_extended_factoryz8ExtendedInstrumentationRegistry._locate_extended_factorygs=<00><00>-<2D>F<EFBFBD><1C>V<EFBFBD>n<EFBFBD>G<EFBFBD><16>"<22><1E>6<>6<>v<EFBFBD>w<EFBFBD>G<><07><1E><07>'<27>'<27> .<2E> rc<00><><00>|j|<01>j|g<01>}|r$td|j<00>dt |<03><00><02><04><00>y)Nz6multiple instrumentation implementations specified in z inheritance hierarchy: )<05>!_collect_management_factories_for<6F>
difference<EFBFBD> TypeError<6F>__name__<5F>list)rrr!<00>existing_factoriess r<00>_check_conflictsz0ExtendedInstrumentationRegistry._check_conflictspsQ<00><00>!<21>C<>C<> <12>
<EFBFBD>
<14>*<2A>g<EFBFBD>Y<EFBFBD>
<1F> <1B> <1E><1B><1A>?<3F>?<3F>D<EFBFBD>);<3B>$<<3C>><3E><0E> <0E> rc<00>H<00>||<01>}t|t<00>s t||<03>}|tk7r|jsd|_t <00>|j <00>|j |<|j<00>|j|<|j<00>|j|<|S)NT) <0B>
isinstancer<00>_ClassInstrumentationAdapter<65> _extended<65>_install_instrumented_lookups<70>manager_getter<65>_manager_finders<72> state_getter<65>_state_finders<72> dict_getter<65> _dict_finders)rrr!r"s rrz7ExtendedInstrumentationRegistry._extended_class_manager{s<><00><00><19>&<26>/<2F><07><19>'<27><<3C>0<>2<>6<EFBFBD>7<EFBFBD>C<>G<EFBFBD> <12>l<EFBFBD> "<22>4<EFBFBD>><3E>><3E>"<22>D<EFBFBD>N<EFBFBD> )<29> +<2B>(/<2F>(><3E>(><3E>(@<40><04><1D><1D>f<EFBFBD>%<25>&-<2D>&:<3A>&:<3A>&<<3C><04><1B><1B>F<EFBFBD>#<23>%,<2C>%8<>%8<>%:<3A><04><1A><1A>6<EFBFBD>"<22><16>rc<00>&<00>tj|<01>}t<00>}|D][}|j|<04>}|<05>|j |j
<00><00>2t D]}||<04>}|<07><01>nd}|j |<07><00>]|jd<01>|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)r<00>class_hierarchy<68>set<65>opt_manager_of_class<73>addr!r<00>discard)rr<00> hierarchy<68> factories<65>memberr"r r!s rr%zAExtendedInstrumentationRegistry._collect_management_factories_for<6F>s<><00><00><19>(<28>(<28><13>-<2D> <09><17>E<EFBFBD> <09><1F>F<EFBFBD><1A>/<2F>/<2F><06>7<>G<EFBFBD><16>"<22><19> <0A> <0A>g<EFBFBD>o<EFBFBD>o<EFBFBD>.<2E>5<>F<EFBFBD>$<24>V<EFBFBD>n<EFBFBD>G<EFBFBD><1E>*<2A><1D>6<>
#<23>G<EFBFBD><19> <0A> <0A>g<EFBFBD>&<26> <20> <12><19><19>$<24><1F><18>rc<00><><00><01>t<00>|<00>|<01>||jvr(|j|=|j|=|j|=yy<00>N)<05>super<65>
unregisterr2r4r6)rr<00> __class__s <20>rrCz*ExtendedInstrumentationRegistry.unregister<65>sM<00><><00> <0A><07><1A>6<EFBFBD>"<22> <11>T<EFBFBD>*<2A>*<2A> *<2A><14>%<25>%<25>f<EFBFBD>-<2D><14>#<23>#<23>F<EFBFBD>+<2B><14>"<22>"<22>6<EFBFBD>*<2A> +rc<00>r<00> |jj|t<00>}||<01>S#t$rYywxYwrA)r2<00>getr r')rrr s rr:z4ExtendedInstrumentationRegistry.opt_manager_of_class<73>sC<00><00> <1F><19>*<2A>*<2A>.<2E>.<2E><13>0<><0E>F<EFBFBD><1A>#<23>;<3B> <1E><> <19> <18><17> <18>s <00> *<00> 6<03>6c<00><><00> |jj|t<00>}||<01>}|<03>tj|d|<01><00><02><00>|S#t
$rtj|d|<01><00><02><00>wxYw)Nz2Can't locate an instrumentation manager for class )r2rFr <00>orm_exc<78>UnmappedClassErrorr')rrr r"s r<00>manager_of_classz0ExtendedInstrumentationRegistry.manager_of_class<73>s<><00><00> <1B><19>*<2A>*<2A>.<2E>.<2E>s<EFBFBD>4K<34>L<>F<EFBFBD><1D>S<EFBFBD>k<EFBFBD>G<EFBFBD><16><EFBFBD><1D>0<>0<><17>H<><13><05>N<><12><12><1B>N<EFBFBD><4E><19> <0E><19>,<2C>,<2C><13>I<>#<23><15>O<><0E> <0E> <0E>s <00> A<00>#A*c<00>|<00>|<01> td<01><00>|jj|jt<00>|<01>S<00>NzNone has no persistent state.)<05>AttributeErrorr4rFrDr <00>r<00>instances r<00>state_ofz(ExtendedInstrumentationRegistry.state_of<6F>sE<00><00> <13> <1B> <20>!@<40>A<> A<>
<EFBFBD>t<EFBFBD>"<22>"<22>&<26>&<26> <14> <1E> <1E> 5<>
<EFBFBD>
<12><14> rc<00>|<00>|<01> td<01><00>|jj|jt<00>|<01>SrL)rMr6rFrDr
rNs r<00>dict_ofz'ExtendedInstrumentationRegistry.dict_of<6F>sE<00><00> <13> <1B> <20>!@<40>A<> A<>
<EFBFBD>t<EFBFBD>!<21>!<21>%<25>%<25> <14> <1E> <1E> 4<>
<EFBFBD>
<12><14> r)r(<00>
__module__<EFBFBD> __qualname__<5F>__doc__<5F>weakref<65>WeakKeyDictionaryr2r4r6r/r#r+rr%rCr:rJrPrR<00> __classcell__<5F>rDs@rrr[sm<00><><00><08> 1<>w<EFBFBD>0<>0<>2<><14>.<2E>W<EFBFBD>.<2E>.<2E>0<>N<EFBFBD>-<2D>G<EFBFBD>-<2D>-<2D>/<2F>M<EFBFBD><15>I<EFBFBD><1E> <0E><17>"<19>6+<2B> <1F><1B>"<14>rrc<00>v<00>eZdZdZd<02>Zd<03>Zd<04>Zd<05>Zd<06>Zd<07>Z d<08>Z
d <09>Z d
<EFBFBD>Z d <0B>Z d <0C>Zd <0A>Zd<0E>Zd<0F>Zd<10>Zd<11>Zd<12>Zy)<14>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.
c<00><00>yrA<00><00>rrs r<00>__init__zInstrumentationManager.__init__<5F><00><00><00> rc<00><00>t|d|<02>y<00>N<>_default_class_manager<65><01>setattr<74>rrr"s r<00>managezInstrumentationManager.manage<67>s<00><00><0F><06>0<>'<27>:rc<00><00>t|d<01>yrb<00><01>delattrrfs rrCz!InstrumentationManager.unregister<65>s <00><00><0F><06>0<>1rc<00> <00>d<01>}|S)Nc<00><00>|jSrA)rcrs rrFz2InstrumentationManager.manager_getter.<locals>.get<65>s<00><00><16>-<2D>-<2D> -rr])rrrFs rr1z%InstrumentationManager.manager_getter<65>s<00><00> .<2E><13>
rc<00><00>yrAr]<00>rr<00>key<65>insts r<00>instrument_attributez+InstrumentationManager.instrument_attributer`rc<00><00>yrAr]rns r<00>post_configure_attributez/InstrumentationManager.post_configure_attributer`rc<00><00>t|||<03>yrArdrns r<00>install_descriptorz)InstrumentationManager.install_descriptor s<00><00><0F><06><03>T<EFBFBD>"rc<00><00>t||<02>yrAri<00>rrros r<00>uninstall_descriptorz+InstrumentationManager.uninstall_descriptor <00> <00><00><0F><06><03>rc<00><00>t|||<03>yrArd)rrro<00>implementations r<00>install_memberz%InstrumentationManager.install_members<00><00><0F><06><03>^<5E>,rc<00><00>t||<02>yrArirws r<00>uninstall_memberz'InstrumentationManager.uninstall_memberryrc<00>,<00>tj|<03>SrA)r<00>prepare_instrumentation)rrro<00>collection_classs r<00>instrument_collection_classz2InstrumentationManager.instrument_collection_classs<00><00><1A>2<>2<>3C<33>D<>Drc<00><00>|jSrA)<01>__dict__<5F>rrrOs r<00>get_instance_dictz(InstrumentationManager.get_instance_dicts<00><00><17> <20> <20> rc<00><00>yrAr]r<>s r<00>initialize_instance_dictz/InstrumentationManager.initialize_instance_dictr`rc<00><00>t|d|<03>y<00>N<>_default_staterd)rrrO<00>states r<00> install_statez$InstrumentationManager.install_states<00><00><0F><08>*<2A>E<EFBFBD>2rc<00><00>t|d<01>yr<>rir<>s r<00> remove_statez#InstrumentationManager.remove_state!s <00><00><0F><08>*<2A>+rc<00><00>d<01>S)Nc<00><00>t|d<01>Sr<>)r)rOs r<00><lambda>z5InstrumentationManager.state_getter.<locals>.<lambda>%s <00><00><07><08>2B<32> Crr]r^s rr3z#InstrumentationManager.state_getter$s<00><00>C<>Crc<00><00><00><01><00><01>fd<01>S)Nc<00>(<00><02><00>j<00>|<00>SrA)r<>)rprrs <20><>rr<>z4InstrumentationManager.dict_getter.<locals>.<lambda>(s<00><><00>D<EFBFBD>2<>2<>6<EFBFBD>4<EFBFBD>@rr]r^s``rr5z"InstrumentationManager.dict_getter's <00><><00>@<40>@rN)r(rSrTrUr_rgrCr1rqrsrurxr|r~r<>r<>r<>r<>r<>r3r5r]rrr[r[<00>s_<00><00><08>( <0A>;<3B>2<><13>  <0A> <0A>#<23><1D>-<2D><1D>E<01>!<21> <0A>3<>,<2C>D<01>Arr[c<00><><00><00>eZdZdZd<02>Zd<03>Zd<04>Zd<05>Zdd<06>Z<08>fd<07>Z d<08>Z
d <09>Z d
<EFBFBD>Z d <0B>Z d <0C>Zd <0A>Zdd<0E>Zd<0F>Zdd<10>Zd<11>Zd<12>Zd<13>Zd<14>Z<16>xZS)r.z?Adapts a user-defined InstrumentationManager to a ClassManager.c<00><><00>||_|jj|<01>|_|jj|<01>|_t j ||<01>yrA)<07>_adaptedr3<00>
_get_stater5<00> _get_dictrr_)rr<00>overrides rr_z%_ClassInstrumentationAdapter.__init__.sE<00><00> <20><04> <0A><1E>-<2D>-<2D>4<>4<>V<EFBFBD><<3C><04><0F><1D><1D><1D>2<>2<>6<EFBFBD>:<3A><04><0E><14><1D><1D>d<EFBFBD>F<EFBFBD>+rc<00>P<00>|jj|j|<00>yrA)r<>rgr<00>rs rrgz#_ClassInstrumentationAdapter.manage5s<00><00> <0C> <0A> <0A><1C><1C>T<EFBFBD>[<5B>[<5B>$<24>/rc<00>P<00>|jj|j|<00>yrA)r<>rCrr<>s rrCz'_ClassInstrumentationAdapter.unregister8s<00><00> <0C> <0A> <0A> <20> <20><14><1B><1B>d<EFBFBD>3rc<00>L<00>|jj|j<00>SrA)r<>r1rr<>s rr1z+_ClassInstrumentationAdapter.manager_getter;s<00><00><13>}<7D>}<7D>+<2B>+<2B>D<EFBFBD>K<EFBFBD>K<EFBFBD>8<>8rc<00><><00>tj||||<03>|s(|jj|j||<02>yyrA)rrqr<>r)rrorp<00>
propagateds rrqz1_ClassInstrumentationAdapter.instrument_attribute>s8<00><00><14>)<29>)<29>$<24><03>T<EFBFBD>:<3A>F<><19> <10>M<EFBFBD>M<EFBFBD> .<2E> .<2E>t<EFBFBD>{<7B>{<7B>C<EFBFBD><14> F<>rc<00>x<00><01>t<00>|<00>|<01>|jj|j|||<00>yrA)rBrsr<>r)rrorDs <20>rrsz5_ClassInstrumentationAdapter.post_configure_attributeCs.<00><><00> <0A><07>(<28><13>-<2D> <0C> <0A> <0A>.<2E>.<2E>t<EFBFBD>{<7B>{<7B>C<EFBFBD><14>c<EFBFBD><19>Krc<00>R<00>|jj|j||<02>yrA)r<>rur)rrorps rruz/_ClassInstrumentationAdapter.install_descriptorGs<00><00> <0C> <0A> <0A>(<28>(<28><14><1B><1B>c<EFBFBD>4<EFBFBD>@rc<00>P<00>|jj|j|<01>yrA)r<>rxr<00>rros rrxz1_ClassInstrumentationAdapter.uninstall_descriptorJs<00><00> <0C> <0A> <0A>*<2A>*<2A>4<EFBFBD>;<3B>;<3B><03><rc<00>R<00>|jj|j||<02>yrA)r<>r|r)rror{s rr|z+_ClassInstrumentationAdapter.install_memberMs<00><00> <0C> <0A> <0A>$<24>$<24>T<EFBFBD>[<5B>[<5B>#<23>~<7E>Frc<00>P<00>|jj|j|<01>yrA)r<>r~rr<>s rr~z-_ClassInstrumentationAdapter.uninstall_memberPs<00><00> <0C> <0A> <0A>&<26>&<26>t<EFBFBD>{<7B>{<7B>C<EFBFBD>8rc<00>P<00>|jj|j||<02>SrA)r<>r<>r)rror<>s rr<>z8_ClassInstrumentationAdapter.instrument_collection_classSs%<00><00><13>}<7D>}<7D>8<>8<> <10>K<EFBFBD>K<EFBFBD><13>.<2E>
<EFBFBD>
rc<00>x<00>t|jdd<00>}|r
||||<03>Stj||||<03>S)N<>initialize_collection)rr<>rr<>)rror<>r!<00>delegates rr<>z2_ClassInstrumentationAdapter.initialize_collectionXsC<00><00><1A>4<EFBFBD>=<3D>=<3D>*A<>4<EFBFBD>H<><08> <13><1B>C<EFBFBD><15><07>0<> 0<><1F>5<>5<><14>c<EFBFBD>5<EFBFBD>'<27><0E> rc<00>t<00>|jj|j<00>}|j||<01>|SrA)r<00>__new__<5F>setup_instance)rr<>rOs r<00> new_instancez)_ClassInstrumentationAdapter.new_instanceas/<00><00><17>;<3B>;<3B>&<26>&<26>t<EFBFBD>{<7B>{<7B>3<><08> <0C><1B><1B>H<EFBFBD>e<EFBFBD>,<2C><17>rc<00>H<00>|j|<01>ry|j|<01>S)z<>Install a default InstanceState if none is present.
A private convenience method used by the __init__ decorator.
F)<02> has_stater<65>rNs r<00>_new_state_if_nonez/_ClassInstrumentationAdapter._new_state_if_nonefs$<00><00>
<10>><3E>><3E>(<28> #<23><18><17>&<26>&<26>x<EFBFBD>0<> 0rc<00><><00>|jj|j|<01>|<02>|j||<00>}|jj |j||<02>|SrA)r<>r<>r<00>_state_constructorr<72>)rrOr<>s rr<>z+_ClassInstrumentationAdapter.setup_instancepsR<00><00> <0C> <0A> <0A>.<2E>.<2E>t<EFBFBD>{<7B>{<7B>H<EFBFBD>E<> <10>=<3D><18>+<2B>+<2B>H<EFBFBD>d<EFBFBD>;<3B>E<EFBFBD> <0A> <0A> <0A>#<23>#<23>D<EFBFBD>K<EFBFBD>K<EFBFBD><18>5<EFBFBD>A<><14> rc<00>P<00>|jj|j|<01>yrA)r<>r<>rrNs r<00>teardown_instancez._ClassInstrumentationAdapter.teardown_instancezs<00><00> <0C> <0A> <0A>"<22>"<22>4<EFBFBD>;<3B>;<3B><08>9rc<00>Z<00> |j|<01>y#tj$rYywxYw)NTF)r<>rH<00>NO_STATErNs rr<>z&_ClassInstrumentationAdapter.has_state}s2<00><00> <18> <10>O<EFBFBD>O<EFBFBD>H<EFBFBD> %<25><18><><17><1F><1F> <19><18> <19>s <00><00>*<03>*c<00><00>|jSrA)r<>r<>s rr3z)_ClassInstrumentationAdapter.state_getter<65>s <00><00><13><EFBFBD><EFBFBD>rc<00><00>|jSrA)r<>r<>s rr5z(_ClassInstrumentationAdapter.dict_getter<65>s <00><00><13>~<7E>~<7E>r)FrA)r(rSrTrUr_rgrCr1rqrsrurxr|r~r<>r<>r<>r<>r<>r<>r<>r3r5rXrYs@rr.r.+si<00><><00>I<>,<2C>0<>4<>9<>G<01>
L<01>A<01>=<3D>G<01>9<>
<EFBFBD>
<0E><18>
1<><15>:<3A><18><1F>rr.c<00><><00>tttjtjtj
tj <00><01><00>y)a<>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.
<20><04>instance_state<74> instance_dictrJr:N)<07>_install_lookups<70>dict<63>_instrumentation_factoryrPrRrJr:r]rrr0r0<00>s8<00><00><15> <0C>3<><<3C><<3C>2<>:<3A>:<3A>5<>F<>F<>!9<>!N<>!N<> 
<EFBFBD>rc<00>j<00>tttttt
<00><01><00>dt _y)zRestore simplified lookups.r<>FN)r<>r<>r r
r r r<>r/r]rr<00>_reinstall_default_lookupsr<73><00>s)<00><00><14> <0C>0<>.<2E>4<>!<<3C> 
<EFBFBD><06>*/<2F><1C>&rc<00>j<00>|da|da|da|datxt_xt
_t _txt_xt
_t _txt_xt
_t _txt_xt_xt
_t _y)Nr<4E>r<>rJr:)r<>r<>rJr:<00>orm_baser<00>orm_instrumentation<6F>orm_util)<01>lookupss rr<>r<><00>s<><00><00><1D>-<2D>.<2E>N<EFBFBD><1B>O<EFBFBD>,<2C>M<EFBFBD><1E>1<>2<><14>"<22>#9<>:<3A><18> <17><17>H<EFBFBD><1B><17>j<EFBFBD>7<><1B>*<2A> <16><16>H<EFBFBD><1A><16>Z<EFBFBD>5<><1B>)<29> <19><19>H<EFBFBD><1D><19>
<EFBFBD> ;<3B><1B>,<2C>4H<01>H<01>H<EFBFBD>!<21>H<01>H<EFBFBD>$A<>H<01><12>'<27><1B>0r)rUrV<00>r<00>ormrrr<>rrrHr r<>r<><00>orm.instrumentationr
r r r rrrrrrr<>r[r.r0r<>r<>r]rr<00><module>r<>s<><00><01><04>"<0F><13><1C>"<22><1D> <20>8<>"<22>6<>9<>=<3D>7<>.<2E>8<>;<3B><17><04>27<>
A<01>A<><17> <04> {<14>&<<3C>{<14>~$<24>%<25><02><13>,<2C>/G<>/F<01><13>+<2B>IA<01>IA<01>X^<1E><<3C>^<1E>B<06>.
/<2F>Hr