[Zope-Checkins] CVS: Zope/lib/python/BDBStorage - BDBFullStorage.py:1.76 BDBMinimalStorage.py:1.33 BerkeleyBase.py:1.46 _helper.c:1.5

Jim Fulton cvs-admin at zope.org
Fri Nov 28 11:45:14 EST 2003


Update of /cvs-repository/Zope/lib/python/BDBStorage
In directory cvs.zope.org:/tmp/cvs-serv3783/lib/python/BDBStorage

Modified Files:
	BDBFullStorage.py BDBMinimalStorage.py BerkeleyBase.py 
	_helper.c 
Log Message:
Merged Jeremy and Tim's changes from the zodb33-devel-branch.


=== Zope/lib/python/BDBStorage/BDBFullStorage.py 1.75 => 1.76 ===
--- Zope/lib/python/BDBStorage/BDBFullStorage.py:1.75	Thu Oct  2 19:56:13 2003
+++ Zope/lib/python/BDBStorage/BDBFullStorage.py	Fri Nov 28 11:44:43 2003
@@ -24,7 +24,7 @@
 from ZODB import POSException
 from ZODB.utils import p64, U64
 from ZODB.referencesf import referencesf
-from ZODB.TimeStamp import TimeStamp
+from persistent.TimeStamp import TimeStamp
 from ZODB.ConflictResolution import ConflictResolvingStorage, ResolvedSerial
 
 from BDBStorage import db, ZERO
@@ -484,11 +484,13 @@
             # given in the call is not the same as the last stored serial
             # number.  First, attempt application level conflict
             # resolution, and if that fails, raise a ConflictError.
-            data = self.tryToResolveConflict(oid, oserial, serial, data)
-            if data:
+            rdata = self.tryToResolveConflict(oid, oserial, serial, data)
+            if rdata:
                 conflictresolved = True
+                data = rdata
             else:
-                raise POSException.ConflictError(serials=(oserial, serial))
+                raise POSException.ConflictError(
+                    oid=oid, serials=(oserial, serial), data=data)
         # Do we already know about this version?  If not, we need to record
         # the fact that a new version is being created.  version will be the
         # empty string when the transaction is storing on the non-version


=== Zope/lib/python/BDBStorage/BDBMinimalStorage.py 1.32 => 1.33 ===
--- Zope/lib/python/BDBStorage/BDBMinimalStorage.py:1.32	Thu Oct  2 14:17:32 2003
+++ Zope/lib/python/BDBStorage/BDBMinimalStorage.py	Fri Nov 28 11:44:43 2003
@@ -262,11 +262,13 @@
             # The object exists in the database, but the serial number
             # given in the call is not the same as the last stored serial
             # number.  Raise a ConflictError.
-            data = self.tryToResolveConflict(oid, oserial, serial, data)
-            if data:
+            rdata = self.tryToResolveConflict(oid, oserial, serial, data)
+            if rdata:
                 conflictresolved = True
+                data = rdata
             else:
-                raise POSException.ConflictError(serials=(oserial, serial))
+                raise POSException.ConflictError(
+                    oid=oid, serials=(oserial, serial), data=data)
         # Optimistically write to the serials and pickles table.  Be sure
         # to also update the oids table for this object too.
         newserial = self._serial


=== Zope/lib/python/BDBStorage/BerkeleyBase.py 1.45 => 1.46 ===
--- Zope/lib/python/BDBStorage/BerkeleyBase.py:1.45	Thu Oct  2 18:14:00 2003
+++ Zope/lib/python/BDBStorage/BerkeleyBase.py	Fri Nov 28 11:44:43 2003
@@ -32,7 +32,6 @@
 from ZODB.lock_file import lock_file
 from ZODB.BaseStorage import BaseStorage
 from ZODB.referencesf import referencesf
-import ThreadLock
 import zLOG
 
 GBYTES = 1024 * 1024 * 1000
@@ -219,7 +218,7 @@
         self._is_read_only = config.read_only
 
         # Instantiate a pack lock
-        self._packlock = ThreadLock.allocate_lock()
+        self._packlock = threading.RLock()
         self._stop = self._closed = False
         # Initialize a few other things
         self._prefix = prefix


=== Zope/lib/python/BDBStorage/_helper.c 1.4 => 1.5 ===
--- Zope/lib/python/BDBStorage/_helper.c:1.4	Mon Jan 20 17:17:01 2003
+++ Zope/lib/python/BDBStorage/_helper.c	Fri Nov 28 11:44:43 2003
@@ -23,10 +23,17 @@
 #error "Must be using at least Python 2.2"
 #endif
 
+/* Increment an 8-byte unsigned integer (represented as an 8-byte raw string),
+ * by a Python integer.
+ * The arguments are an 8-byte Python string, and a Python int or long.
+ * The result is an 8-byte Python string, representing their sum.
+ * XXX It's unclear what this intends to do if the sum overflows an 8-byte
+ * XXX unsigned integer.  _PyLong_AsByteArray should raise OverflowError then.
+ */
 static PyObject*
 helper_incr(PyObject* self, PyObject* args)
 {
-    PyObject *pylong, *incr, *sum;
+    PyObject *pylong = NULL, *incr, *sum = NULL, *result = NULL;
     char *s, x[8];
     int len, res;
 
@@ -42,21 +49,25 @@
     pylong = _PyLong_FromByteArray(s, len,
                                    0 /* big endian */,
                                    0 /* unsigned */);
-    
+
     if (!pylong)
         return NULL;
 
     sum = PyNumber_Add(pylong, incr);
     if (!sum)
-        return NULL;
+	goto err;
 
     res = _PyLong_AsByteArray((PyLongObject*)sum, x, 8,
                               0 /* big endian */,
                               0 /* unsigned */);
     if (res < 0)
-        return NULL;
+	goto err;
 
-    return PyString_FromStringAndSize(x, 8);
+    result = PyString_FromStringAndSize(x, 8);
+ err:
+    Py_XDECREF(pylong);
+    Py_XDECREF(sum);
+    return result;
 }
 
 




More information about the Zope-Checkins mailing list