[Zodb-checkins] CVS: ZODB4/BDBStorage - BDBMinimalStorage.py:2.0

Barry Warsaw barry@wooz.org
Wed, 4 Dec 2002 14:42:20 -0500


Update of /cvs-repository/ZODB4/BDBStorage
In directory cvs.zope.org:/tmp/cvs-serv16911

Modified Files:
      Tag: 2.0
	BDBMinimalStorage.py 
Log Message:
Get rid of some pre-Python 2.2.2 b/c cruft.


=== Added File ZODB4/BDBStorage/BDBMinimalStorage.py === (440/540 lines abridged)
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################

"""Berkeley storage without undo or versioning.
"""

__version__ = '$Revision: 2.0 $'[-2:][0]

import time
import threading

# This uses the Dunn/Kuchling PyBSDDB v3 extension module available from
# http://pybsddb.sourceforge.net.  It is compatible with release 3.4 of
# PyBSDDB3.
from bsddb3 import db

from ZODB import POSException
from ZODB.utils import u64, p64
from ZODB.Serialize import findrefs
from ZODB.ConflictResolution import ConflictResolvingStorage, ResolvedSerial

# BerkeleyBase class provides some common functionality for BerkeleyDB-based
# storages.  It in turn inherits from BaseStorage which itself provides some
# common storage functionality.
from BDBStorage.BerkeleyBase import BerkeleyBase, PackStop, _WorkThread

ABORT = 'A'
COMMIT = 'C'
PRESENT = 'X'
ZERO = '\0'*8

# Number of seconds for the autopack thread to sleep before checking to see if
# it's time for another autopack run.  Lower numbers mean more processing,
# higher numbers mean less responsiveness to shutdown requests.  10 seconds
# seems like a good compromise.
AUTOPACK_CHECK_SLEEP = 10




[-=- -=- -=- 440 lines omitted -=- -=- -=-]

                    c.delete()
                    rec = c.next()
                    deltas = {}
                    self._update(deltas, data, -1)
                    for oid, delta in deltas.items():
                        refcount = u64(self._refcounts.get(oid, ZERO)) + delta
                        if refcount <= 0:
                            self._oidqueue.append(oid, txn)
                        else:
                            self._refcounts.put(oid, p64(refcount), txn=txn)
            finally:
                c.close()
            # We really do want this down here, since _decrefPickle() could
            # add more items to the queue.
            orec = self._oidqueue.consume(txn)
        assert len(self._oidqueue) == 0

    #
    # Stuff we don't support
    #

    def supportsTransactionalUndo(self):
        return False

    def supportsUndo(self):
        return False

    def supportsVersions(self):
        return False

    # Don't implement these
    #
    # versionEmpty(self, version)
    # versions(self, max=None)
    # loadSerial(self, oid, serial)
    # getSerial(self, oid)
    # transactionalUndo(self, tid, transaction)
    # undoLog(self, first=0, last=-20, filter=None)
    # history(self, oid, version=None, size=1, filter=None)
    # iterator(self, start=None, stop=None)



class _Autopack(_WorkThread):
    def __init__(self, storage, frequency):
        _WorkThread.__init__(self, storage, frequency, 'autopacking')

    def _dowork(self, now):
        # Run the autopack phase
        self._storage.pack('ignored')