Annotation of ExtFile/TM.pyc, revision 1.1

1.1     ! dwinter     1: mò
        !             2: L
µCc@s”dZd&k&lZ&dklZ&dklZ&dklZ&dfd„ƒYZ  def&d„ƒYZ
        !             3: e ƒZeiZei
Z
eiZeiZd    S(
        !             4: sæ
        !             5: TMRegistry and ProxyTM
        !             6: 
        !             7: Use case
        !             8: --------
        !             9: 
        !            10: Persistent objects (ExtFiles) need to participate in ZODB transactions.
        !            11: ExtFiles perform all operations using temporary files which are saved on
        !            12: commit or deleted on abort.
        !            13: 
        !            14: Constraints
        !            15: -----------
        !            16: 
        !            17: - TransactionManagers (TM) must not be persistent themselves, i.e. must
        !            18:   not have a _p_jar attribute.
        !            19: 
        !            20: - We have to make sure the ExtFile's _abort is called *before* the ZODB
        !            21:   destroys the attributes of the persistent object.
        !            22: 
        !            23: Solution
        !            24: --------
        !            25: 
        !            26: - ProxyTM is a subclass of TM.TM that keeps a (hard) reference to the
        !            27:   (wrapped) persistent object it manages. Calls to _begin, _finish, and
        !            28:   _abort are forwarded to the target object.
        !            29: 
        !            30: - TMRegistry is a module-level container for ProxyTMs. It creates and
        !            31:   holds ProxyTMs keyed by (target_id, thread_id).
        !            32: 
        !            33: - ExtFiles implement _finish and _abort and register with the machinery
        !            34:   by calling TM.register(self).
        !            35: 
        !            36: - On commit (or abort) the ProxyTM notifies its target object and removes
        !            37:   itself from the registry.
        !            38: 
        !            39: Hacks
        !            40: -----
        !            41: 
        !            42: - We manipulate the transaction's _resources attribute directly. This is
        !            43:   to guarantee the ProxyTM is processed before other resources. There may
        !            44:   be a way to achieve this using official APIs only, but I can't seem to
        !            45:   find one.
        !            46: 
        !            47: (&sTM(&saq_base(&s    get_ident(&stransactiont
        !            48: TMRegistryc&BsPtZ&d&„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z    RS(    Nc&&Cs
h|_&dS(&N(tselft_tms(&R&((t*/usr/local/testzope/Products/ExtFile/TM.pyt__init__6s&cCstt&|&ƒ&ƒ&tƒfS(&N(tidtaq_basettargett    get_ident(R&R((Rtgetid9s&cCsN|i&|&ƒ&p:&|i|&ƒ&}t|&ƒ&}|iƒ&||i|<d&Sn&&dS(Ni&i(    R&tcontainsRR RtProxyTMttmt    _registerR(R&RRR((Rtregister<s&&&&
        !            49: &
&&cCs5|i&|&ƒ&o!&|i|&ƒ&}|i|=d&Sn&&dS(Ni&i(R&R
        !            50: RR  RR(R&RR((RtremoveEs
        !            51: &&&
        !            52: &&cCs|i&|&ƒ&}|ii|ƒ&S(&N(R&R  RRRthas_key(R&RR((RR
        !            53: Ls&&cCs|i&|&ƒ&}|ii|ƒ&S(&N(R&R RRRtget(R&RR((RRPs&&c&&Cs
t|iƒ&S(&N(tlenR&R(&R&((Rt__len__Ts&c&&Cs
        !            54: t|ƒ&S(&N(RR&(&R&((RtcountWs&(
        !            55: t__name__t
        !            56: __module__RR    RRR
        !            57: RRR(((RR4s                        Rc&Bs5tZ&d&„Zd„Zd„Zd„Zd„ZRS(NcCs
|&|_dS(&N(RR&t_target(R&R((RR]s&c&CsSti&|ƒ&&tiƒ}&t|&d&ƒo&&|&iiƒ}|&ii
        !            58: d|ƒ&n&&dS(Nt
        !            59: _resourcesi(tTMR
R&ttransactionRt&tthasattrRtpopt&rtinsert(R&RR((RR
`s
        !            60: &
&&&c&&&Cs
|i&iƒS(&N(R&Rt_begin(&R&((RR is&c&&Cs(ti&|iƒ&o&|iiƒSn&&dS(&N(tregistryRR&Rt_finish(&R&((RR"ls&&c&&Cs(ti&|iƒ&o&|iiƒSn&&dS(&N(R!RR&Rt_abort(&R&((RR#ps&&(RRRR
R R"R#(((RR[s
        !            61:                 N(t__doc__tShared.DC.ZRDB.TMRtAcquisitionRtthreadRtProducts.ExtFileRRRR!RRR
        !            62: R(RRRRRRRRR!R
        !            63: R((Rt&?,s
&
&
&
'   &   &   &   &

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>