mò !N5?c@s¸dZdkZdkZdkZdkZdklZeiZdkTei Z ei Z dZ dei fd„ƒYZ de fd„ƒYZd e fd „ƒYZd fd „ƒYZd fd„ƒYZdefd„ƒYZdefd„ƒYZeeƒdefd„ƒYZeeƒdefd„ƒYZeeƒd„Zedjo^edƒZded(R t __class__Rtnametid(R ((Rt__repr__{scCs|iiƒ|iƒdS(sÇ Commit all changes and start a new transaction. This method does not implement any disk operation, but takes care of managing the cache. Post-override. N(R R tclearR(R ((Rtcommits cCs|iiƒ|iƒdS(sÇ Take back all changes and start a new transaction. Overriding is normally not needed. This method only takes care of managing the cache. Post-override. N(R R RR(R ((RRs iicCsM|io?x<|iiƒD]'\}\}}||jodSqqWndS(st Return true in case the current transaction includes changes to the database, false otherwise. iiN(R R titemstkeytstatetvaluetmodified(R R#R"R R!((Rtchangeds  ic CsÆ|i}x8|iƒD]*\}\}}||jo ||=qqW||ƒ}||joe|i o|i ƒdSnt t d|ƒ|d|jo$t t dƒ|iƒtd‚qÂndS(s˜ Remove all unmodified entries from the cache. If self.autocommit and the cache cleanup did not reduce the size below the MAXCACHESIZE limit, a .commit() will be executed automatically. Otherwise the processing continues. If the cache size hits 2 * MAXCACHESIZE, a forced .rollback() is done and an error raised. Ns*Cache overflow: %i modified items in cacheis$Cache overflow: forced a .rollback()s,cache overflow; last transaction rolled back(R R RR R!R"t unmodifiedR tsizet MAXCACHESIZEt autocommitRtlogt SYSTEM_ERRORRR( R R R'R%R R!R"R R&((Rt free_cacheªs$         cCs td‚dS(sù Read and return the value corresponding to key. If checkonly is true, only the availability of a value has to be checked. Override this method with an implementation that accesses the disk. s key not foundN(tKeyError(R R t checkonly((RtreadËs cCsd|f|i|R RRRtrecovertrecover_callbackRA(R ((RREŒs  cCs td‚dS(sc Internal callback used to update the index when the storage recovery collector finds a record. old_position is only given as additional information, new_position contains the position of the found record. This method must be overridden to account for the different indexing schemes. s#.recover_callback() not implementedN(R(R RBRCRD((RRF˜s cCs1ttd|ƒ|iiƒp td‚ndS(s Checks the consistency of the index and raises an RecreateIndexError in case the index is found to be inconsistent. Validation takes places for the data on disk. The in memory data is not checked. sValidating index for %ssindex is inconsistentN(R)R>R RtvalidateR(R ((Rtvalidate_index¦s cCsttd|ƒdS(sg Checks the consistency of the storage and raises an RecoverError in case it is found to be inconsistent. Validation takes places for the data on disk. The in memory data is not checked. XXX This currently does nothing since storages don't support validation yet. sValidating storage for %sN(R)R>R (R ((Rtvalidate_storage´s cCs|iƒ|ii|ƒdS(s¼ Issues a backup request to the storage using archive which defaults to the storage filename + '.backup'. This causes an implicit .rollback() to be done. N(R RRtbackuptarchive(R RK((RRJÄs cCs td‚dS(sg Restores the storage from an archive file. XXX Currently does NOT work. s.restore() not implemented !N(t SystemError(R RK((RtrestoreÏs(ii(ii(ii(+RRRRRRRRR R=R(tFirstKeytLastKeyR RRRRRRRRR$R R'R+R.R/R,R1R3R2R5R6R<R?R@RERFRHRIRJRM(((RR+sH        !  !      R7cBsYtZdZeZd„Zed„Zd„Zd„Zd„Z d„Z dd„Z RS( sþ Cursor for BeeBaseDict subclasses. The read/read_key/write methods assume that the dictionary uses a BeeKeyValueStorage instances as storage facility. Note that modifying the targetted dictionary while using a cursor can cause the cursor to skip new entries or fail due to deleted items. Especially deleting the key to which the cursor currently points can cause errors to be raised. In all other cases, the cursor will be repositioned. cCs.||_||_|i|_|i|_dS(N(tdictR R6R R"(R RPR6((RR ês   cCs|iii|ƒ|_}|od|i|joTxQ|iƒo6|i|joPn|i|jo td‚q6q6Wtd‚n||_||_dS(sÔ Position the index cursor to index[key]. If value is given, index[key] == value is assured. key may also be FirstKey or LastKey (in which case value has to be None). s key not foundN(R RPRR6R R"tnextR,(R R R"R6((Rtpositionñs   cCs^|i}|ip#|i|i|iƒ|i}n|iƒ}|i|_|i|_|S(s‘ Moves to the next entry in the dictionary. Returns true on success, false if the end-of-data has been reached. N(R R6R9RRR R"RQtrc(R R6RS((RRQs      cCs^|i}|ip#|i|i|iƒ|i}n|iƒ}|i|_|i|_|S(s• Moves to the previous entry in the dictionary. Returns true on success, false if the end-of-data has been reached. N(R R6R9RRR R"tprevRS(R R6RS((RRTs      cCs|i|iS(s# Reads the object from the dict to which the cursor currently points. This method assumes a BeeKeyValueStorage instance in self.storage and an index that holds copies of the key objects. Override if this is not the case. N(R RPR (R ((RR.'s cCs|iii|iƒS(s¡ Reads the key object from the dict to which the cursor currently points. This method is intended for dictionaries that store hash values in the index. Normally, accessing the instance variable .key would give the current key object. This method assumes a BeeKeyValueStorage instance in self.storage. Override if this is not the case. N(R RPRtread_keyR"(R ((RRU3s icCs||i|is    cCs¼g}|ii}xG|iiƒD]6\}\}}|djo|i ||fƒq"q"W|ii }xM|i i ƒD]<}||ƒ\}}||ƒp|i ||fƒqxqxW|S(sš Return a list of items. The method does not load any data into the cache, but does take notice of uncommitted changes. iN(RvR RR.R RR R!R"RwR2RxRRyRj(R R.RvR"RxR!R Rj((RRTs    cCsX|io|iƒo td‚n|i|dƒ}|djo|Snt ||ƒS(s+ Return a cursor instance for this kind of dictionary. Note that cursors operate with the data on disk. The method will raise an error in case there are uncommitted changes pending. In case the key is not found, default is returned instead. suncommitted data existsN( R R R$RRkR RR6R4t BeeDictCursor(R R R4R6((RR6js   cCsit|ii|ƒƒ}y|ii|||ƒWn0t j o$t t d|ƒ||i|