Commit 565a1afd authored by Jim Fulton's avatar Jim Fulton

Merged Jeremy and Tim's changes from the zodb33-devel-branch.

parent 322ceda2
......@@ -14,7 +14,7 @@
"""Berkeley storage with full undo and versioning support.
$Revision: 1.75 $
$Revision: 1.76 $
"""
import time
......@@ -24,7 +24,7 @@ from struct import pack, unpack
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 @@ class BDBFullStorage(BerkeleyBase, ConflictResolvingStorage):
# 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
......
......@@ -15,7 +15,7 @@
"""Berkeley storage without undo or versioning.
"""
__version__ = '$Revision: 1.32 $'[-2:][0]
__version__ = '$Revision: 1.33 $'[-2:][0]
from ZODB import POSException
from ZODB.utils import p64, U64
......@@ -262,11 +262,13 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
# 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
......
......@@ -32,7 +32,6 @@ from BDBStorage import db, ZERO
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 @@ class BerkeleyBase(BaseStorage):
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
......
......@@ -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 @@ helper_incr(PyObject* self, PyObject* args)
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;
}
......
......@@ -17,13 +17,14 @@ import time
import unittest
import threading
from persistent.TimeStamp import TimeStamp
from ZODB import DB
from ZODB.Transaction import Transaction
from ZODB.referencesf import referencesf
from ZODB.TimeStamp import TimeStamp
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_pickle
from Persistence import Persistent
from persistent import Persistent
import BDBStorage
if BDBStorage.is_available:
......
......@@ -18,8 +18,7 @@ import unittest
import BDBStorage
from BDBStorage.tests.ZODBTestBase import ZODBTestBase
from Persistence import PersistentMapping
from persistent.mapping import PersistentMapping
class InsertMixin:
......
......@@ -32,7 +32,7 @@ else:
from BDBStorage.tests.ZODBTestBase import ZODBTestBase
from BDBStorage.tests.BerkeleyTestBase import BerkeleyTestBase
from Persistence import Persistent
from persistent import Persistent
ZERO = '\0'*8
......
......@@ -21,7 +21,7 @@ import unittest
import BDBStorage
from BDBStorage.tests.ZODBTestBase import ZODBTestBase
from Persistence import PersistentMapping
from persistent.mapping import PersistentMapping
......
......@@ -63,7 +63,7 @@ import marshal
from bsddb3 import db
from ZODB import utils
from ZODB.TimeStamp import TimeStamp
from persistent.TimeStamp import TimeStamp
from ZODB.FileStorage import FileStorage
from BDBStorage.BDBFullStorage import BDBFullStorage
......
......@@ -63,7 +63,7 @@ import marshal
from bsddb3 import db
from ZODB import utils
from ZODB.TimeStamp import TimeStamp
from persistent.TimeStamp import TimeStamp
from ZODB.FileStorage import FileStorage
from BDBStorage.BDBFullStorage import BDBFullStorage
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment