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 @@ ...@@ -14,7 +14,7 @@
"""Berkeley storage with full undo and versioning support. """Berkeley storage with full undo and versioning support.
$Revision: 1.75 $ $Revision: 1.76 $
""" """
import time import time
...@@ -24,7 +24,7 @@ from struct import pack, unpack ...@@ -24,7 +24,7 @@ from struct import pack, unpack
from ZODB import POSException from ZODB import POSException
from ZODB.utils import p64, U64 from ZODB.utils import p64, U64
from ZODB.referencesf import referencesf from ZODB.referencesf import referencesf
from ZODB.TimeStamp import TimeStamp from persistent.TimeStamp import TimeStamp
from ZODB.ConflictResolution import ConflictResolvingStorage, ResolvedSerial from ZODB.ConflictResolution import ConflictResolvingStorage, ResolvedSerial
from BDBStorage import db, ZERO from BDBStorage import db, ZERO
...@@ -484,11 +484,13 @@ class BDBFullStorage(BerkeleyBase, ConflictResolvingStorage): ...@@ -484,11 +484,13 @@ class BDBFullStorage(BerkeleyBase, ConflictResolvingStorage):
# given in the call is not the same as the last stored serial # given in the call is not the same as the last stored serial
# number. First, attempt application level conflict # number. First, attempt application level conflict
# resolution, and if that fails, raise a ConflictError. # resolution, and if that fails, raise a ConflictError.
data = self.tryToResolveConflict(oid, oserial, serial, data) rdata = self.tryToResolveConflict(oid, oserial, serial, data)
if data: if rdata:
conflictresolved = True conflictresolved = True
data = rdata
else: 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 # 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 # the fact that a new version is being created. version will be the
# empty string when the transaction is storing on the non-version # empty string when the transaction is storing on the non-version
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"""Berkeley storage without undo or versioning. """Berkeley storage without undo or versioning.
""" """
__version__ = '$Revision: 1.32 $'[-2:][0] __version__ = '$Revision: 1.33 $'[-2:][0]
from ZODB import POSException from ZODB import POSException
from ZODB.utils import p64, U64 from ZODB.utils import p64, U64
...@@ -262,11 +262,13 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage): ...@@ -262,11 +262,13 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
# The object exists in the database, but the serial number # The object exists in the database, but the serial number
# given in the call is not the same as the last stored serial # given in the call is not the same as the last stored serial
# number. Raise a ConflictError. # number. Raise a ConflictError.
data = self.tryToResolveConflict(oid, oserial, serial, data) rdata = self.tryToResolveConflict(oid, oserial, serial, data)
if data: if rdata:
conflictresolved = True conflictresolved = True
data = rdata
else: 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 # Optimistically write to the serials and pickles table. Be sure
# to also update the oids table for this object too. # to also update the oids table for this object too.
newserial = self._serial newserial = self._serial
......
...@@ -32,7 +32,6 @@ from BDBStorage import db, ZERO ...@@ -32,7 +32,6 @@ from BDBStorage import db, ZERO
from ZODB.lock_file import lock_file from ZODB.lock_file import lock_file
from ZODB.BaseStorage import BaseStorage from ZODB.BaseStorage import BaseStorage
from ZODB.referencesf import referencesf from ZODB.referencesf import referencesf
import ThreadLock
import zLOG import zLOG
GBYTES = 1024 * 1024 * 1000 GBYTES = 1024 * 1024 * 1000
...@@ -219,7 +218,7 @@ class BerkeleyBase(BaseStorage): ...@@ -219,7 +218,7 @@ class BerkeleyBase(BaseStorage):
self._is_read_only = config.read_only self._is_read_only = config.read_only
# Instantiate a pack lock # Instantiate a pack lock
self._packlock = ThreadLock.allocate_lock() self._packlock = threading.RLock()
self._stop = self._closed = False self._stop = self._closed = False
# Initialize a few other things # Initialize a few other things
self._prefix = prefix self._prefix = prefix
......
...@@ -23,10 +23,17 @@ ...@@ -23,10 +23,17 @@
#error "Must be using at least Python 2.2" #error "Must be using at least Python 2.2"
#endif #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* static PyObject*
helper_incr(PyObject* self, PyObject* args) helper_incr(PyObject* self, PyObject* args)
{ {
PyObject *pylong, *incr, *sum; PyObject *pylong = NULL, *incr, *sum = NULL, *result = NULL;
char *s, x[8]; char *s, x[8];
int len, res; int len, res;
...@@ -48,15 +55,19 @@ helper_incr(PyObject* self, PyObject* args) ...@@ -48,15 +55,19 @@ helper_incr(PyObject* self, PyObject* args)
sum = PyNumber_Add(pylong, incr); sum = PyNumber_Add(pylong, incr);
if (!sum) if (!sum)
return NULL; goto err;
res = _PyLong_AsByteArray((PyLongObject*)sum, x, 8, res = _PyLong_AsByteArray((PyLongObject*)sum, x, 8,
0 /* big endian */, 0 /* big endian */,
0 /* unsigned */); 0 /* unsigned */);
if (res < 0) 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 ...@@ -17,13 +17,14 @@ import time
import unittest import unittest
import threading import threading
from persistent.TimeStamp import TimeStamp
from ZODB import DB from ZODB import DB
from ZODB.Transaction import Transaction from ZODB.Transaction import Transaction
from ZODB.referencesf import referencesf from ZODB.referencesf import referencesf
from ZODB.TimeStamp import TimeStamp
from ZODB.tests.MinPO import MinPO from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_pickle from ZODB.tests.StorageTestBase import zodb_pickle
from Persistence import Persistent from persistent import Persistent
import BDBStorage import BDBStorage
if BDBStorage.is_available: if BDBStorage.is_available:
......
...@@ -18,8 +18,7 @@ import unittest ...@@ -18,8 +18,7 @@ import unittest
import BDBStorage import BDBStorage
from BDBStorage.tests.ZODBTestBase import ZODBTestBase from BDBStorage.tests.ZODBTestBase import ZODBTestBase
from Persistence import PersistentMapping from persistent.mapping import PersistentMapping
class InsertMixin: class InsertMixin:
......
...@@ -32,7 +32,7 @@ else: ...@@ -32,7 +32,7 @@ else:
from BDBStorage.tests.ZODBTestBase import ZODBTestBase from BDBStorage.tests.ZODBTestBase import ZODBTestBase
from BDBStorage.tests.BerkeleyTestBase import BerkeleyTestBase from BDBStorage.tests.BerkeleyTestBase import BerkeleyTestBase
from Persistence import Persistent from persistent import Persistent
ZERO = '\0'*8 ZERO = '\0'*8
......
...@@ -21,7 +21,7 @@ import unittest ...@@ -21,7 +21,7 @@ import unittest
import BDBStorage import BDBStorage
from BDBStorage.tests.ZODBTestBase import ZODBTestBase from BDBStorage.tests.ZODBTestBase import ZODBTestBase
from Persistence import PersistentMapping from persistent.mapping import PersistentMapping
......
...@@ -63,7 +63,7 @@ import marshal ...@@ -63,7 +63,7 @@ import marshal
from bsddb3 import db from bsddb3 import db
from ZODB import utils from ZODB import utils
from ZODB.TimeStamp import TimeStamp from persistent.TimeStamp import TimeStamp
from ZODB.FileStorage import FileStorage from ZODB.FileStorage import FileStorage
from BDBStorage.BDBFullStorage import BDBFullStorage from BDBStorage.BDBFullStorage import BDBFullStorage
......
...@@ -63,7 +63,7 @@ import marshal ...@@ -63,7 +63,7 @@ import marshal
from bsddb3 import db from bsddb3 import db
from ZODB import utils from ZODB import utils
from ZODB.TimeStamp import TimeStamp from persistent.TimeStamp import TimeStamp
from ZODB.FileStorage import FileStorage from ZODB.FileStorage import FileStorage
from BDBStorage.BDBFullStorage import BDBFullStorage 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