diff --git a/NEWS.txt b/NEWS.txt index 53e0eb26cc9d7ed3e097a03250a15209b891fced..34f4ac394b91e3c912e28a98eaa378bcee905bb6 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,12 +1,20 @@ Whats new in ZODB 3.8.5 (2009-12-16) ==================================== -Bugs Fixed: +Bug Fixed: - A ZEO threading bug could cause transactions to read inconsistent data. (This sometimes caused an AssertionError in Connection._setstate_noncurrent.) +New Feature: + +- The standard storages, FileStorage, ClientStorage, DemoStorage, and + MappingStorage now allow the version argument to history and load to + be ommitted. This is to make it easier to write application code + that works with ZODB 3.8 and later versions, which don't support + versions. + Whats new in ZODB 3.8.4 (2009-10-01) ==================================== diff --git a/src/ZEO/ClientStorage.py b/src/ZEO/ClientStorage.py index db851d042e99ffc924a1f3d65115ecab1459b7c0..42e79d8c45ce13d2bb1086408212b90f1bc04de4 100644 --- a/src/ZEO/ClientStorage.py +++ b/src/ZEO/ClientStorage.py @@ -679,7 +679,7 @@ class ClientStorage(object): self._tbuf.invalidate(oid, "") return tid, oids - def history(self, oid, version, length=1): + def history(self, oid, version='', length=1): """Storage API: return a sequence of HistoryEntry objects. This does not support the optional filter argument defined by @@ -702,7 +702,7 @@ class ClientStorage(object): """Storage API: load a historical revision of an object.""" return self._server.loadSerial(oid, serial) - def load(self, oid, version): + def load(self, oid, version=''): """Storage API: return the data for a given object. This returns the pickle data and serial number for the object diff --git a/src/ZEO/tests/testZEO.py b/src/ZEO/tests/testZEO.py index e38e16ee7c79da9125a6c596f065f84a5c979500..af6ae874ed8b0c71a0fba789bf37a962cf1afdbb 100644 --- a/src/ZEO/tests/testZEO.py +++ b/src/ZEO/tests/testZEO.py @@ -188,6 +188,12 @@ class GenericTests( key = '%s:%s' % (self._storage._storage, self._storage._server_addr) self.assertEqual(self._storage.sortKey(), key) + def checkOmitVersionOnLoadAndHistory(self): + db = ZODB.DB(self._storage) + self.assertEqual(self._storage.load('\0'*8), + self._storage.load('\0'*8, '')) + self._storage.history('\0'*8) + class FullGenericTests( GenericTests, Cache.StorageWithCache, diff --git a/src/ZODB/BaseStorage.py b/src/ZODB/BaseStorage.py index 4446d6dc094a492b520ccebb645e46b61b40be88..e90bbddb81e7c136d63dcc0348ae046c3c7689a5 100644 --- a/src/ZODB/BaseStorage.py +++ b/src/ZODB/BaseStorage.py @@ -113,7 +113,7 @@ class BaseStorage(UndoLogCompatible): def getSize(self): return len(self)*300 # WAG! - def history(self, oid, version, length=1, filter=None): + def history(self, oid, version='', length=1, filter=None): return () def new_oid(self): diff --git a/src/ZODB/DemoStorage.py b/src/ZODB/DemoStorage.py index a32d0ff6f978fb9b087897ce506f8b8f59ce99c7..75533d632f35a7ec8fe5b6c372b1ef3fed57498d 100644 --- a/src/ZODB/DemoStorage.py +++ b/src/ZODB/DemoStorage.py @@ -218,7 +218,7 @@ class DemoStorage(BaseStorage): finally: self._lock_release() - def load(self, oid, version): + def load(self, oid, version=''): self._lock_acquire() try: try: diff --git a/src/ZODB/FileStorage/FileStorage.py b/src/ZODB/FileStorage/FileStorage.py index 35e82f24bfece2ca19cad2c969e0e37c1d9470ed..99c45b9d4eb31f742e416df4b75cf8c4de89ecad 100644 --- a/src/ZODB/FileStorage/FileStorage.py +++ b/src/ZODB/FileStorage/FileStorage.py @@ -463,7 +463,7 @@ class FileStorage(BaseStorage.BaseStorage, except TypeError: raise TypeError("invalid oid %r" % (oid,)) - def load(self, oid, version): + def load(self, oid, version=''): """Return pickle data and serial number.""" self._lock_acquire() try: diff --git a/src/ZODB/MappingStorage.py b/src/ZODB/MappingStorage.py index cbf87eb2856c963e47973bf5d5e762ce28e810cb..d4d4519dfb8fdcfa83c0a7f63882c030be8880bc 100644 --- a/src/ZODB/MappingStorage.py +++ b/src/ZODB/MappingStorage.py @@ -55,7 +55,7 @@ class MappingStorage(BaseStorage): finally: self._lock_release() - def load(self, oid, version): + def load(self, oid, version=''): self._lock_acquire() try: p = self._index[oid] diff --git a/src/ZODB/tests/testDemoStorage.py b/src/ZODB/tests/testDemoStorage.py index 0e2ffdda555ed8ad112588c46ff2f99d5c9b4429..bce68f149d0e796adff167bc20e614fcc15c7d38 100644 --- a/src/ZODB/tests/testDemoStorage.py +++ b/src/ZODB/tests/testDemoStorage.py @@ -64,6 +64,12 @@ class DemoStorageTests(StorageTestBase.StorageTestBase, self.assertEqual(s2.load(ZODB.utils.z64, ''), self._storage.load(ZODB.utils.z64, '')) + def checkOmitVersionOnLoadAndHistory(self): + db = DB(self._storage) + self.assertEqual(self._storage.load('\0'*8), + self._storage.load('\0'*8, '')) + self._storage.history('\0'*8) + class DemoStorageWrappedBase(DemoStorageTests): diff --git a/src/ZODB/tests/testFileStorage.py b/src/ZODB/tests/testFileStorage.py index 7a16d20d4a173f8e037f8752fef67fd9cdc2c5ba..49973719caaeb23213574725df3bef21732aff75 100644 --- a/src/ZODB/tests/testFileStorage.py +++ b/src/ZODB/tests/testFileStorage.py @@ -330,6 +330,12 @@ class FileStorageTests( else: self.assertNotEqual(next_oid, None) + def checkOmitVersionOnLoadAndHistory(self): + db = ZODB.DB(self._storage) + self.assertEqual(self._storage.load('\0'*8), + self._storage.load('\0'*8, '')) + self._storage.history('\0'*8) + class FileStorageRecoveryTest( StorageTestBase.StorageTestBase, RecoveryStorage.RecoveryStorage, diff --git a/src/ZODB/tests/testMappingStorage.py b/src/ZODB/tests/testMappingStorage.py index 5cd6b0730ce4e3fbe5771991381000c3a27fccd4..01be0ffb0349d456a8d172ffebfc086f47b26815 100644 --- a/src/ZODB/tests/testMappingStorage.py +++ b/src/ZODB/tests/testMappingStorage.py @@ -37,6 +37,12 @@ class MappingStorageTests(StorageTestBase.StorageTestBase, # have this limit, so we inhibit this test here. pass + def checkOmitVersionOnLoadAndHistory(self): + db = ZODB.DB(self._storage) + self.assertEqual(self._storage.load('\0'*8), + self._storage.load('\0'*8, '')) + self._storage.history('\0'*8) + def test_suite(): suite = unittest.makeSuite(MappingStorageTests, 'check') return suite