mò &U²Ic @s¶dZy-edjodkZeZn dkZWn)ej odkZeie=‚nXeZZei Z ei Z dkZdk Z ei djo"dkZdklZddUndfd„ƒYZdefd „ƒYZd d dddddd d „Zd d d dddddd„Zd d d dddddddd„ Zd„Zd„Zy0dkZ[ei ƒdjo d e_nWnej od e_nXdS(s(Support for BerkeleyDB 3.2 through 4.2. tbsddb3Ns2.3(srefsç class _iter_mixin(UserDict.DictMixin): def _make_iter_cursor(self): cur = self.db.cursor() key = id(cur) self._cursor_refs[key] = ref(cur, self._gen_cref_cleaner(key)) return cur def _gen_cref_cleaner(self, key): # use generate the function for the weakref callback here # to ensure that we do not hold a strict reference to cur # in the callback. return lambda ref: self._cursor_refs.pop(key, None) def __iter__(self): try: cur = self._make_iter_cursor() # FIXME-20031102-greg: race condition. cursor could # be closed by another thread before this call. # since we're only returning keys, we call the cursor # methods with flags=0, dlen=0, dofs=0 key = cur.first(0,0,0)[0] yield key next = cur.next while 1: try: key = next(0,0,0)[0] yield key except _bsddb.DBCursorClosedError: cur = self._make_iter_cursor() # FIXME-20031101-greg: race condition. cursor could # be closed by another thread before this call. cur.set(key,0,0,0) next = cur.next except _bsddb.DBNotFoundError: return except _bsddb.DBCursorClosedError: # the database was modified during iteration. abort. return def iteritems(self): try: try: cur = self._make_iter_cursor() except AttributeError: return # FIXME-20031102-greg: race condition. cursor could # be closed by another thread before this call. kv = cur.first() key = kv[0] yield kv next = cur.next while 1: try: kv = next() key = kv[0] yield kv except _bsddb.DBCursorClosedError: cur = self._make_iter_cursor() # FIXME-20031101-greg: race condition. cursor could # be closed by another thread before this call. cur.set(key,0,0,0) next = cur.next except _bsddb.DBNotFoundError: return except _bsddb.DBCursorClosedError: # the database was modified during iteration. abort. return t _iter_mixincBstZRS(N(t__name__t __module__(((t+/data/zmath/lib/python2.4/bsddb/__init__.pyR’st _DBWithCursorcBs¼tZdZd„Zd„Zd„Zdd„Zd„Zd„Zd„Z d „Z d „Z d „Z d „Z d „Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s˜ A simple wrapper around DB that makes it look like the bsddbobject in the old module. It uses a cursor as needed to provide DB traversal. cCs8||_|iidƒd|_d|_h|_dS(Ni(tdbtselftset_get_returns_nonetNonetdbct saved_dbc_keyt _cursor_refs(RR((Rt__init__šs    cCs|iƒdS(N(Rtclose(R((Rt__del__°scCsZ|idjoF|iiƒ|_|idj o |ii|iƒd|_qVndS(N(RR R RtcursorR tset(R((Rt _checkCursor³s icCs³|iog|i}d|_|o=y |idddƒd|_Wq`tij oq`Xn|i ƒ~nx;|i i ƒD]*}|ƒ}|dj o|i ƒqqWdS(Ni( RR tcR tsavetcurrentR RtDBErrorRR tvaluestcref(RRRR((Rt _closeCursors¾s        cCs!|idjo td‚ndS(Ns$BSDDB object has already been closed(RRR terror(R((Rt _checkOpenÎscCs |idj S(N(RRR (R((RtisOpenÒscCs|iƒt|iƒS(N(RRtlenR(R((Rt__len__Õs cCs|iƒ|i|S(N(RRRtkey(RR((Rt __getitem__Ùs cCs%|iƒ|iƒ||i|R;R7R9R4((Rthashopens      c CsÒt||ƒ} t|ƒ} ti| ƒ} |dj o| i |ƒn|dj o| i|ƒn| i|ƒ|dj o| i|ƒn|dj o| i|ƒn| i|ti| |ƒt| ƒS(N(R1R2R3R4R5R6R7RR8R9R<R R=R>R?R:tbtflagst minkeypaget set_bt_minkeyt maxkeypaget set_bt_maxkeyRDtDB_BTREERFR( R3R2RFRHR6RKRIR<R>R7R9R4((Rtbtopen/s      c Cst||ƒ} t|ƒ} ti| ƒ} |dj o| i |ƒn|dj o| i|ƒn| i|ƒ|dj o| i|ƒn|dj o| i|ƒn| dj o| i| ƒn| dj o| i| ƒn| i|ti| |ƒt| ƒS(N(R1R2R3R4R5R6R7RR8R9R<R R=R>R?R:trnflagstdelimt set_re_delimtrlent set_re_lentsourcet set_re_sourcetpadt set_re_padRDtDB_RECNORFR(R3R2RFROR6R<R>RRRPRTRVR7R9R4((RtrnopenAs$        cCsztiƒ}|dj o.|djo|id|ƒqGtd‚n|idtiti Bti Bti Bti Bƒ|S(NiPiscachesize must be >= 20480t.( RtDBEnvR7R6R t set_cachesizeRRDt DB_PRIVATEt DB_CREATEt DB_THREADt DB_INIT_LOCKt DB_INIT_MPOOL(R6R7((RR5Ts    /cCs·|djo ti}n“|djo d}n||djo ti}nb|djo ti}nH|djo1ti}tii|ƒoti |ƒq¬n t d‚|ti BS(NtrtrwitwRtns+flags should be one of 'r', 'w', 'c' or 'n'( R2Rt DB_RDONLYR4R^tostpathtisfileR3tunlinkRR_(R2R3R4((RR1^s           i(iii(R0Rt_pybsddbt_bsddbt ImportErrortsystmodulesRt_dbt __version__RRRgtversiontUserDicttweakreftrefRRR RGRNRYR5R1tthreadR_(RGRqR5RYRuR1RsRpRRlRnRRvRNRRRkRg((Rt?%s>            LŠ!!'