mò Tã¸Ec@sŠdZdkZdkZdklZlZlZlZlZdk l Z dk l Z dfd„ƒYZ dfd„ƒYZd „ZdS( s‹Tools for using FileStorage data files. TODO: This module needs tests. Caution: This file needs to be kept in sync with FileStorage.py. N(s TRANS_HDRsDATA_HDRs TRANS_HDR_LENs DATA_HDR_LENsDATA_VERSION_HDR_LEN(su64(s TimeStampt TxnHeadercBsVtZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( sàObject representing a transaction record header. Attribute Position Value --------- -------- ----- tid 0- 8 transaction id length 8-16 length of entire transaction record - 8 status 16-17 status of transaction (' ', 'u', 'p'?) user_len 17-19 length of user field (pack code H) descr_len 19-21 length of description field (pack code H) ext_len 21-23 length of extensions (pack code H) cCs ||_||_|iƒdS(N(tfiletselft_filetpost_post _read_header(RRR((t+/data/zmath/zope/lib/python/ZODB/fstools.pyt__init__*s  cCse|ii|iƒ|iitƒ|_tit |iƒ\|_ |_ |_ |_ |_|_dS(N(RRtseekRtreadt TRANS_HDR_LENt_hdrtstructtunpackt TRANS_HDRttidtlengthtstatustuser_lent descr_lentext_len(R((RR/scCsãd|_d|_h|_|ip|ip|ipdSn|ii|i t ƒ|io|ii |iƒ|_n|io|ii |iƒ|_n|io1|ii |iƒ|_ t i|i ƒ|_ndS(s%Load user, descr, and ext attributes.tN(RtusertdescrtextRRRRR RR R t_exttcPickletloads(R((Rt read_meta5s      cCs |it|i|i|iS(N(RRR RRR(R((Rtget_data_offsetEscCs t|iƒS(N(t TimeStampRR(R((Rt get_timestampIscCs@|iƒ}|i||i}|ii|ƒ|ii|ƒS(N( RRtdata_offRRtdata_lenRR R (RR"R!((Rt get_raw_dataLs cCsU|i|id}|ii|ƒ|iidƒ}|pdSnt |i|ƒS(Ni( RRRtoffRR R tstNoneR(RR$R%((Rtnext_txnRs cCsb|idjodSn|ii|idƒt|iidƒƒ}t|i|i|dƒS(Nii( RRR&RR tu64R ttlenR(RR)((Rtprev_txnZs ( t__name__t __module__t__doc__RRRRR R#R'R*(((RRs        t DataHeadercBs)tZdZd„Zd„Zd„ZRS(sƒObject representing a data record header. Attribute Position Value --------- -------- ----- oid 0- 8 object id serial 8-16 object serial numver prev_rec_pos 16-24 position of previous data record for object txn_pos 24-32 position of txn header version_len 32-34 length of version data_len 34-42 length of data nonversion_pos 42-50* position of nonversion data record prev_version_pos 50-58* pos of previous version data record * these attributes are only present if version_len != 0. cCs ||_||_|iƒdS(N(RRRRRR(RRR((RRrs  cCsà|ii|iƒ|iitƒ|_tit |it ƒ\|_ |_ }}|_}t|ƒ|_ t|ƒ|_t|ƒ|_|io7|it }t|d ƒ|_t|dƒ|_nd|_d|_dS(Ni(RRR RR tDATA_VERSION_HDR_LENR R RtDATA_HDRt DATA_HDR_LENtoidtserialt prev_rec_posttxn_post version_lenR"R(R%tnonversion_postprev_version_posR&(RR5R%R"R4((RRws4   cCs[|i|i}|io||it7}n |t7}|idjo|d7}n|S(sReturn offset of next record.iiN(RRR"R$R6R/R1(RR$((Rt next_offsetˆs  (R+R,R-RRR9(((RR.as   cCs@|iddƒt|idƒƒd}t||iƒ|ƒS(s8Return transaction located before current file position.iøÿÿÿiiN(tfR R(R R)Rttell(R:R)((RR*“s(R-RR tZODB.FileStorage.formatRR0R R1R/t ZODB.utilsR(tpersistent.TimeStampRRR.R*( RR R R1RRR(R/R0RR.R*((Rt?s  %  D2