[Zodb-checkins] CVS: ZODB4/src/zodb/storage/tests - base.py:1.6.4.3 basic.py:1.6.4.2 mt.py:1.4.4.2 packable.py:1.4.4.3 readonly.py:1.4.4.3 recovery.py:1.4.4.6 revision.py:1.4.4.1 synchronization.py:1.4.4.2 test_autopack.py:1.9.4.1 undo.py:1.5.4.5
Barry Warsaw
barry@wooz.org
Thu, 13 Mar 2003 14:40:14 -0500
Update of /cvs-repository/ZODB4/src/zodb/storage/tests
In directory cvs.zope.org:/tmp/cvs-serv9877/storage/tests
Modified Files:
Tag: opaque-pickles-branch
base.py basic.py mt.py packable.py readonly.py recovery.py
revision.py synchronization.py test_autopack.py undo.py
Log Message:
> Next step: get rid of the tuple in the argument list.
Completed.
Also, reorder the arguments to restore() so that data and refs are
buddies again, just like in the store() call.
I believe we're ready to merge back to the head.
=== ZODB4/src/zodb/storage/tests/base.py 1.6.4.2 => 1.6.4.3 ===
--- ZODB4/src/zodb/storage/tests/base.py:1.6.4.2 Thu Mar 13 11:11:14 2003
+++ ZODB4/src/zodb/storage/tests/base.py Thu Mar 13 14:39:43 2003
@@ -31,7 +31,7 @@
from transaction import get_transaction
from zodb.db import DB
-from zodb.serialize import ConnectionObjectReader, ObjectWriter
+from zodb.serialize import ConnectionObjectReader, ObjectWriter, findrefs
from zodb.ztransaction import Transaction
from zodb.storage.tests.minpo import MinPO
from zodb.storage.base import ZERO, BerkeleyConfig
@@ -129,7 +129,7 @@
self._close()
def _dostore(self, oid=None, revid=None, data=None, version=None,
- already_pickled=0, user=None, description=None):
+ already_pickled=False, user=None, description=None):
"""Do a complete storage transaction. The defaults are:
- oid=None, ask the storage for a new oid
@@ -143,12 +143,17 @@
oid = self._storage.newObjectId()
if revid is None:
revid = ZERO
+ refs = []
if data is None:
data = MinPO(7)
- if type(data) == types.IntType:
+ if isinstance(data, types.IntType):
data = MinPO(data)
if not already_pickled:
- data = zodb_pickle(data)
+ data, refs = zodb_pickle(data)
+ elif isinstance(data, types.TupleType):
+ data, refs = data
+ else:
+ refs = findrefs(data)
if version is None:
version = ''
# Begin the transaction
@@ -160,7 +165,7 @@
try:
self._storage.tpcBegin(t)
# Store an object
- r1 = self._storage.store(oid, revid, data, version, t)
+ r1 = self._storage.store(oid, revid, data, refs, version, t)
# Finish the transaction
r2 = self._storage.tpcVote(t)
revid = handle_serials(oid, r1, r2)
@@ -172,7 +177,7 @@
def _dostoreNP(self, oid=None, revid=None, data=None, version=None,
user=None, description=None):
- return self._dostore(oid, revid, data, version, already_pickled=1,
+ return self._dostore(oid, revid, data, version, already_pickled=True,
user=user, description=description)
# The following methods depend on optional storage features.
@@ -221,7 +226,8 @@
t = Transaction()
t.note("initial database creation")
self._storage.tpcBegin(t)
- self._storage.store(ZERO, None, zodb_pickle(root), '', t)
+ data, refs = zodb_pickle(root)
+ self._storage.store(ZERO, None, data, refs, '', t)
self._storage.tpcVote(t)
self._storage.tpcFinish(t)
=== ZODB4/src/zodb/storage/tests/basic.py 1.6.4.1 => 1.6.4.2 ===
--- ZODB4/src/zodb/storage/tests/basic.py:1.6.4.1 Thu Mar 13 11:31:51 2003
+++ ZODB4/src/zodb/storage/tests/basic.py Thu Mar 13 14:39:43 2003
@@ -59,7 +59,7 @@
# different Transaction object than the one we've begun on.
self._storage.tpcBegin(t)
self.assertRaises(StorageTransactionError, self._storage.store,
- 0, 0, (0, 0), 0, Transaction())
+ 0, 0, 0, 0, 0, Transaction())
try:
self._storage.abortVersion('dummy', Transaction())
@@ -76,7 +76,7 @@
assert 0, "Should have failed, invalid transaction."
self.assertRaises(StorageTransactionError, self._storage.store,
- 0, 1, (2, 3), 4, Transaction())
+ 0, 1, 2, 3, 4, Transaction())
self._storage.tpcAbort(t)
def checkSerialIsNoneForInitialRevision(self):
@@ -86,8 +86,8 @@
self._storage.tpcBegin(txn)
# Use None for serial. Don't use _dostore() here because that coerces
# serial=None to serial=ZERO.
- r1 = self._storage.store(oid, None, zodb_pickle(MinPO(11)),
- '', txn)
+ data, refs = zodb_pickle(MinPO(11))
+ r1 = self._storage.store(oid, None, data, refs, '', txn)
r2 = self._storage.tpcVote(txn)
self._storage.tpcFinish(txn)
newrevid = handle_serials(oid, r1, r2)
@@ -133,7 +133,8 @@
oid = self._storage.newObjectId()
t = Transaction()
self._storage.tpcBegin(t)
- self._storage.store(oid, ZERO, zodb_pickle(MinPO(5)), '', t)
+ data, refs = zodb_pickle(MinPO(5))
+ self._storage.store(oid, ZERO, data, refs, '', t)
# Now abort this transaction
self._storage.tpcAbort(t)
# Now start all over again
@@ -146,7 +147,8 @@
oid = self._storage.newObjectId()
t = Transaction()
self._storage.tpcBegin(t)
- self._storage.store(oid, ZERO, zodb_pickle(MinPO(5)), '', t)
+ data, refs = zodb_pickle(MinPO(5))
+ self._storage.store(oid, ZERO, data, refs, '', t)
# Now abort this transaction
self._storage.tpcVote(t)
self._storage.tpcAbort(t)
@@ -191,7 +193,7 @@
tid = chr(42) * 8
self._storage.tpcBegin(t, tid)
oid = self._storage.newObjectId()
- data = zodb_pickle(MinPO(8))
- self._storage.store(oid, None, data, '', t)
+ data, refs = zodb_pickle(MinPO(8))
+ self._storage.store(oid, None, data, refs, '', t)
self._storage.tpcVote(t)
self._storage.tpcFinish(t)
=== ZODB4/src/zodb/storage/tests/mt.py 1.4.4.1 => 1.4.4.2 ===
--- ZODB4/src/zodb/storage/tests/mt.py:1.4.4.1 Thu Mar 13 11:44:26 2003
+++ ZODB4/src/zodb/storage/tests/mt.py Thu Mar 13 14:39:43 2003
@@ -114,7 +114,7 @@
return oid
def dostore(self, i):
- data = zodb_pickle(MinPO((self.getName(), i)))
+ data, refs = zodb_pickle(MinPO((self.getName(), i)))
t = Transaction()
oid = self.oid()
self.pause()
@@ -123,7 +123,7 @@
self.pause()
# Always create a new object, signified by None for revid
- r1 = self.storage.store(oid, None, data, [], '', t)
+ r1 = self.storage.store(oid, None, data, refs, '', t)
self.pause()
r2 = self.storage.tpcVote(t)
=== ZODB4/src/zodb/storage/tests/packable.py 1.4.4.2 => 1.4.4.3 ===
--- ZODB4/src/zodb/storage/tests/packable.py:1.4.4.2 Mon Mar 10 18:06:10 2003
+++ ZODB4/src/zodb/storage/tests/packable.py Thu Mar 13 14:39:43 2003
@@ -22,7 +22,7 @@
from zodb.serialize import getDBRoot, ConnectionObjectReader
from zodb.ztransaction import Transaction
from zodb.storage.tests.minpo import MinPO
-from zodb.storage.tests.base import zodb_pickle, zodb_unpickle
+from zodb.storage.tests.base import zodb_unpickle
from zodb.storage.fsdump import dump
=== ZODB4/src/zodb/storage/tests/readonly.py 1.4.4.2 => 1.4.4.3 ===
--- ZODB4/src/zodb/storage/tests/readonly.py:1.4.4.2 Thu Mar 13 11:31:51 2003
+++ ZODB4/src/zodb/storage/tests/readonly.py Thu Mar 13 14:39:43 2003
@@ -52,7 +52,7 @@
self.assertRaises(ReadOnlyError, self._storage.commitVersion,
'', '', t)
self.assertRaises(ReadOnlyError, self._storage.store,
- ZERO, None, ('', ''), '', t)
+ ZERO, None, '', '', '', t)
if IUndoStorage.isImplementedBy(self._storage):
self.assertRaises(ReadOnlyError, self._storage.undo,
=== ZODB4/src/zodb/storage/tests/recovery.py 1.4.4.5 => 1.4.4.6 ===
--- ZODB4/src/zodb/storage/tests/recovery.py:1.4.4.5 Wed Mar 12 16:11:58 2003
+++ ZODB4/src/zodb/storage/tests/recovery.py Thu Mar 13 14:39:43 2003
@@ -161,8 +161,8 @@
datarefs = []
for r in final:
datarefs.append((r.data, r.refs))
- self._dst.restore(r.oid, r.serial, r.data, r.version, r.data_txn,
- r.refs, final)
+ self._dst.restore(r.oid, r.serial, r.data, r.refs, r.version,
+ r.data_txn, final)
self._dst.tpcVote(final)
self._dst.tpcFinish(final)
iter.close()
=== ZODB4/src/zodb/storage/tests/revision.py 1.4 => 1.4.4.1 ===
--- ZODB4/src/zodb/storage/tests/revision.py:1.4 Wed Feb 5 18:28:27 2003
+++ ZODB4/src/zodb/storage/tests/revision.py Thu Mar 13 14:39:43 2003
@@ -17,7 +17,7 @@
from zodb.storage.base import ZERO
from zodb.storage.tests.minpo import MinPO
-from zodb.storage.tests.base import zodb_unpickle, zodb_pickle
+from zodb.storage.tests.base import zodb_unpickle
class RevisionStorage:
=== ZODB4/src/zodb/storage/tests/synchronization.py 1.4.4.1 => 1.4.4.2 ===
--- ZODB4/src/zodb/storage/tests/synchronization.py:1.4.4.1 Thu Mar 13 11:31:51 2003
+++ ZODB4/src/zodb/storage/tests/synchronization.py Thu Mar 13 14:39:43 2003
@@ -103,11 +103,11 @@
def checkStoreNotCommitting(self):
self.verifyNotCommitting(self._storage.store,
- OID, SERIALNO, ("", ""), "", Transaction())
+ OID, SERIALNO, "", "", "", Transaction())
def checkStoreWrongTrans(self):
self.verifyWrongTrans(self._storage.store,
- OID, SERIALNO, ("", ""), "", Transaction())
+ OID, SERIALNO, "", "", "", Transaction())
## def checkNewOidNotCommitting(self):
## self.verifyNotCommitting(self._storage.new_oid)
=== ZODB4/src/zodb/storage/tests/test_autopack.py 1.9 => 1.9.4.1 ===
--- ZODB4/src/zodb/storage/tests/test_autopack.py:1.9 Wed Feb 5 18:28:27 2003
+++ ZODB4/src/zodb/storage/tests/test_autopack.py Thu Mar 13 14:39:43 2003
@@ -287,7 +287,8 @@
obj2 = C()
t = Transaction()
storage.tpcBegin(t)
- obj2sn = storage.store('\0'*7 + '\2', ZERO, zodb_pickle(obj2), '', t)
+ data, refs = zodb_pickle(obj2)
+ obj2sn = storage.store('\0'*7 + '\2', ZERO, data, refs, '', t)
# Now, acquire the condvar lock and start a thread that will do a
# pack, up to the _sweep call. Wait for the _mark() call to
# complete.
@@ -302,7 +303,8 @@
# links the object to root.
root.obj2 = obj2
rootsn = storage.getSerial(ZERO)
- rootsn = storage.store(ZERO, rootsn, zodb_pickle(root), '', t)
+ data, refs = zodb_pickle(root)
+ rootsn = storage.store(ZERO, rootsn, data, refs, '', t)
storage.tpcVote(t)
storage.tpcFinish(t)
# And notify the pack thread that it can do the sweep and collect
@@ -349,12 +351,14 @@
packthread = self._getPackThread(storage)
packthread.start()
self._cv.wait()
- obj2sn = storage.store('\0'*7 + '\2', ZERO, zodb_pickle(obj2), '', t)
+ data, refs = zodb_pickle(obj2)
+ obj2sn = storage.store('\0'*7 + '\2', ZERO, data, refs, '', t)
# Now that the _mark() has finished, complete the transaction, which
# links the object to root.
root.obj2 = obj2
rootsn = storage.getSerial(ZERO)
- rootsn = storage.store(ZERO, rootsn, zodb_pickle(root), '', t)
+ data, refs = zodb_pickle(root)
+ rootsn = storage.store(ZERO, rootsn, data, refs, '', t)
storage.tpcVote(t)
storage.tpcFinish(t)
# And notify the pack thread that it can do the sweep and collect
=== ZODB4/src/zodb/storage/tests/undo.py 1.5.4.4 => 1.5.4.5 ===
--- ZODB4/src/zodb/storage/tests/undo.py:1.5.4.4 Thu Mar 13 11:14:04 2003
+++ ZODB4/src/zodb/storage/tests/undo.py Thu Mar 13 14:39:43 2003
@@ -26,8 +26,8 @@
def _transaction_begin(self):
self.__serials = {}
- def _transaction_store(self, oid, rev, data, vers, trans):
- r = self._storage.store(oid, rev, data, vers, trans)
+ def _transaction_store(self, oid, rev, (data, refs), vers, trans):
+ r = self._storage.store(oid, rev, data, refs, vers, trans)
if r:
if type(r) == types.StringType:
self.__serials[oid] = r
@@ -51,8 +51,9 @@
t.note(note)
self._storage.tpcBegin(t)
self._transaction_begin()
- for oid, rev, data in objs:
- self._transaction_store(oid, rev, data, '', t)
+ # datarefs is a tuple of (data, refs)
+ for oid, rev, datarefs in objs:
+ self._transaction_store(oid, rev, datarefs, '', t)
newrevs[oid] = None
self._transaction_vote(t)
self._storage.tpcFinish(t)
@@ -199,8 +200,7 @@
def checkTwoObjectUndo(self):
eq = self.assertEqual
# Convenience
- p31, p32, p51, p52 = map(zodb_pickle,
- map(MinPO, (31, 32, 51, 52)))
+ p31, p32, p51, p52 = [zodb_pickle(MinPO(i)) for i in (31, 32, 51, 52)]
oid1 = self._storage.newObjectId()
oid2 = self._storage.newObjectId()
revid1 = revid2 = ZERO
@@ -254,9 +254,8 @@
# Convenience
eq = self.assertEqual
unless = self.failUnless
- p30, p31, p32, p50, p51, p52 = map(zodb_pickle,
- map(MinPO,
- (30, 31, 32, 50, 51, 52)))
+ p30, p31, p32, p50, p51, p52 = [zodb_pickle(MinPO(i))
+ for i in (30, 31, 32, 50, 51, 52)]
oid1 = self._storage.newObjectId()
oid2 = self._storage.newObjectId()
revid1 = revid2 = ZERO
@@ -322,15 +321,14 @@
def checkTwoObjectUndoAgain(self):
eq = self.assertEqual
- p31, p32, p33, p51, p52, p53 = map(
- zodb_pickle,
- map(MinPO, (31, 32, 33, 51, 52, 53)))
+ p31, p32, p33, p51, p52, p53 = [zodb_pickle(MinPO(i))
+ for i in (31, 32, 33, 51, 52, 53)]
# Like the above, but the first revision of the objects are stored in
# different transactions.
oid1 = self._storage.newObjectId()
oid2 = self._storage.newObjectId()
- revid1 = self._dostore(oid1, data=p31, already_pickled=1)
- revid2 = self._dostore(oid2, data=p51, already_pickled=1)
+ revid1 = self._dostore(oid1, data=p31, already_pickled=True)
+ revid2 = self._dostore(oid2, data=p51, already_pickled=True)
# Update those same two objects
t = Transaction()
self._storage.tpcBegin(t)
@@ -415,9 +413,7 @@
revid1 = revid_c
oid2 = self._storage.newObjectId()
revid2 = ZERO
- p81, p82, p91, p92 = map(zodb_pickle,
- map(MinPO, (81, 82, 91, 92)))
-
+ p81, p82, p91, p92 = [zodb_pickle(MinPO(i)) for i in (81, 82, 91, 92)]
t = Transaction()
self._storage.tpcBegin(t)
self._transaction_begin()
@@ -570,7 +566,8 @@
for j in range(OBJECTS):
oid = s.newObjectId()
obj = MinPO(i * OBJECTS + j)
- revid = s.store(oid, None, zodb_pickle(obj), '', t)
+ data, refs = zodb_pickle(obj)
+ revid = s.store(oid, None, data, refs, '', t)
orig.append((tid, oid, revid))
s.tpcVote(t)
s.tpcFinish(t)