[Zope3-checkins] CVS: Zope3/src/zodb/storage - base.py:1.21

Barry Warsaw barry@wooz.org
Mon, 17 Mar 2003 15:21:10 -0500


Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv23923

Modified Files:
	base.py 
Log Message:
newObjectId(): Remove a dead chicken, i.e. the last argument, which
isn't part of the public api and is only used internally in this
method here.  We can provide a cleaner implementation anyway.

pack(): Is now defined to take an optional gc flag which specifies
whether to do a full gc in additional to the normal incremental pack.
The default is True and storages which don't provide separated
semantics are free to ignore the gc flag.

For Berkeley storages, "classicpack" -> "gcpack"


=== Zope3/src/zodb/storage/base.py 1.20 => 1.21 ===
--- Zope3/src/zodb/storage/base.py:1.20	Fri Mar 14 12:18:52 2003
+++ Zope3/src/zodb/storage/base.py	Mon Mar 17 15:21:10 2003
@@ -46,6 +46,7 @@
 # of other methods, some of which are overridden here, some of which are not.
 from zodb.lockfile import LockFile
 from zodb.serialize import findrefs
+from zodb.utils import p64, u64
 
 GBYTES = 1024 * 1024 * 1000
 JOIN_TIME = 10
@@ -128,29 +129,15 @@
     def modifiedInVersion(self, oid):
         return ''
 
-    def newObjectId(self, last=None):
-         # 'last' is only for internal use, not part of the public API
+    def newObjectId(self):
         if self._is_read_only:
-            raise ReadOnlyError()
-        if last is None:
-            self._lock_acquire()
-            try:
-                last = self._oid
-                d = ord(last[-1])
-                if d < 255:
-                    last = last[:-1] + chr(d+1)
-                else:
-                    last = self.newObjectId(last[:-1])
-                self._oid = last
-                return last
-            finally:
-                self._lock_release()
-        else:
-            d = ord(last[-1])
-            if d < 255:
-                return last[:-1] + chr(d+1) + '\0'*(8-len(last))
-            else:
-                return self.newObjectId(last[:-1])
+            raise ReadOnlyError
+        self._lock_acquire()
+        try:
+            self._oid = p64(u64(self._oid) + 1)
+            return self._oid
+        finally:
+            self._lock_release()
 
     def registerDB(self, db):
         pass # we don't care
@@ -292,7 +279,7 @@
     def versions(self, max=None):
         return ()
 
-    def pack(self, t):
+    def pack(self, t, gc=True):
         if self._is_read_only:
             raise ReadOnlyError()
 
@@ -440,11 +427,11 @@
       to autopack to.  E.g. if packtime is 14400, autopack will pack to 4
       hours in the past.  For Minimal storage, this value is ignored.
 
-    - classicpack is an integer indicating how often an autopack phase should
-      do a full classic pack.  E.g. if classicpack is 24 and frequence is
-      3600, a classic pack will be performed once per day.  Set to zero to
-      never automatically do classic packs.  For Minimal storage, this value
-      is ignored -- all packs are classic packs.
+    - gcpack is an integer indicating how often an autopack phase should do a
+      full garbage collecting pack.  E.g. if gcpack is 24 and frequence is
+      3600, a gc pack will be performed once per day.  Set to zero to never
+      automatically do gc packs.  For Minimal storage, this value is ignored;
+      all packs are gc packs.
 
     Here are some other miscellaneous configuration variables:
 
@@ -459,7 +446,7 @@
     cachesize = 128 * 1024 * 1024
     frequency = 0
     packtime = 4 * 60 * 60
-    classicpack = 0
+    gcpack = 0
     read_only = False
 
     def __repr__(self):
@@ -476,7 +463,7 @@
 \t----------------------
 \tautopack frequency: %(frequency)s seconds
 \tpack to %(packtime)s seconds in the past
-\tclassic pack every %(classicpack)s autopacks
+\tclassic pack every %(gcpack)s autopacks
 \t>""" % d
 
 
@@ -624,16 +611,13 @@
             self._len = len(self._serials)
         return self._len
 
-    def newObjectId(self, last=None):
-        """Create a new object id.
-
-        If last is provided, the new oid will be one greater than that.
-        """
-        # BAW: the last parameter is undocumented in the UML model
+    def newObjectId(self):
+        """Create a new object id."""
+        newoid = BaseStorage.newObjectId(self)
         if self._len is not None:
             # Increment the cached length
             self._len += 1
-        return BaseStorage.newObjectId(self, last)
+        return newoid
 
     def getSize(self):
         """Return the size of the database."""