Commit cdb94c28 authored by Jim Fulton's avatar Jim Fulton

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.
parent 3550df2a
Whats new in ZODB 3.8.5 (2009-12-16) Whats new in ZODB 3.8.5 (2009-12-16)
==================================== ====================================
Bugs Fixed: Bug Fixed:
- A ZEO threading bug could cause transactions to read inconsistent - A ZEO threading bug could cause transactions to read inconsistent
data. (This sometimes caused an AssertionError in data. (This sometimes caused an AssertionError in
Connection._setstate_noncurrent.) 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) Whats new in ZODB 3.8.4 (2009-10-01)
==================================== ====================================
......
...@@ -679,7 +679,7 @@ class ClientStorage(object): ...@@ -679,7 +679,7 @@ class ClientStorage(object):
self._tbuf.invalidate(oid, "") self._tbuf.invalidate(oid, "")
return tid, oids 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. """Storage API: return a sequence of HistoryEntry objects.
This does not support the optional filter argument defined by This does not support the optional filter argument defined by
...@@ -702,7 +702,7 @@ class ClientStorage(object): ...@@ -702,7 +702,7 @@ class ClientStorage(object):
"""Storage API: load a historical revision of an object.""" """Storage API: load a historical revision of an object."""
return self._server.loadSerial(oid, serial) 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. """Storage API: return the data for a given object.
This returns the pickle data and serial number for the object This returns the pickle data and serial number for the object
......
...@@ -188,6 +188,12 @@ class GenericTests( ...@@ -188,6 +188,12 @@ class GenericTests(
key = '%s:%s' % (self._storage._storage, self._storage._server_addr) key = '%s:%s' % (self._storage._storage, self._storage._server_addr)
self.assertEqual(self._storage.sortKey(), key) 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( class FullGenericTests(
GenericTests, GenericTests,
Cache.StorageWithCache, Cache.StorageWithCache,
......
...@@ -113,7 +113,7 @@ class BaseStorage(UndoLogCompatible): ...@@ -113,7 +113,7 @@ class BaseStorage(UndoLogCompatible):
def getSize(self): def getSize(self):
return len(self)*300 # WAG! return len(self)*300 # WAG!
def history(self, oid, version, length=1, filter=None): def history(self, oid, version='', length=1, filter=None):
return () return ()
def new_oid(self): def new_oid(self):
......
...@@ -218,7 +218,7 @@ class DemoStorage(BaseStorage): ...@@ -218,7 +218,7 @@ class DemoStorage(BaseStorage):
finally: finally:
self._lock_release() self._lock_release()
def load(self, oid, version): def load(self, oid, version=''):
self._lock_acquire() self._lock_acquire()
try: try:
try: try:
......
...@@ -463,7 +463,7 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -463,7 +463,7 @@ class FileStorage(BaseStorage.BaseStorage,
except TypeError: except TypeError:
raise TypeError("invalid oid %r" % (oid,)) raise TypeError("invalid oid %r" % (oid,))
def load(self, oid, version): def load(self, oid, version=''):
"""Return pickle data and serial number.""" """Return pickle data and serial number."""
self._lock_acquire() self._lock_acquire()
try: try:
......
...@@ -55,7 +55,7 @@ class MappingStorage(BaseStorage): ...@@ -55,7 +55,7 @@ class MappingStorage(BaseStorage):
finally: finally:
self._lock_release() self._lock_release()
def load(self, oid, version): def load(self, oid, version=''):
self._lock_acquire() self._lock_acquire()
try: try:
p = self._index[oid] p = self._index[oid]
......
...@@ -64,6 +64,12 @@ class DemoStorageTests(StorageTestBase.StorageTestBase, ...@@ -64,6 +64,12 @@ class DemoStorageTests(StorageTestBase.StorageTestBase,
self.assertEqual(s2.load(ZODB.utils.z64, ''), self.assertEqual(s2.load(ZODB.utils.z64, ''),
self._storage.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): class DemoStorageWrappedBase(DemoStorageTests):
......
...@@ -330,6 +330,12 @@ class FileStorageTests( ...@@ -330,6 +330,12 @@ class FileStorageTests(
else: else:
self.assertNotEqual(next_oid, None) 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( class FileStorageRecoveryTest(
StorageTestBase.StorageTestBase, StorageTestBase.StorageTestBase,
RecoveryStorage.RecoveryStorage, RecoveryStorage.RecoveryStorage,
......
...@@ -37,6 +37,12 @@ class MappingStorageTests(StorageTestBase.StorageTestBase, ...@@ -37,6 +37,12 @@ class MappingStorageTests(StorageTestBase.StorageTestBase,
# have this limit, so we inhibit this test here. # have this limit, so we inhibit this test here.
pass 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(): def test_suite():
suite = unittest.makeSuite(MappingStorageTests, 'check') suite = unittest.makeSuite(MappingStorageTests, 'check')
return suite return suite
......
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