[Zodb-checkins] SVN: ZODB/branches/3.9/src/ZEO/ Fix bug where storages that still supported versions had the size parameter pass by zeo as the version parameter to their history method.

Chris Withers chris at simplistix.co.uk
Fri Nov 20 05:37:28 EST 2009


Log message for revision 105902:
  Fix bug where storages that still supported versions had the size parameter pass by zeo as the version parameter to their history method.

Changed:
  U   ZODB/branches/3.9/src/ZEO/StorageServer.py
  U   ZODB/branches/3.9/src/ZEO/tests/testConversionSupport.py

-=-
Modified: ZODB/branches/3.9/src/ZEO/StorageServer.py
===================================================================
--- ZODB/branches/3.9/src/ZEO/StorageServer.py	2009-11-20 10:29:28 UTC (rev 105901)
+++ ZODB/branches/3.9/src/ZEO/StorageServer.py	2009-11-20 10:37:28 UTC (rev 105902)
@@ -188,7 +188,6 @@
             self.undo = undo
 
         self.getTid = storage.getTid
-        self.history = storage.history
         self.load = storage.load
         self.loadSerial = storage.loadSerial
         record_iternext = getattr(storage, 'record_iternext', None)
@@ -220,6 +219,11 @@
             else:
                 raise
 
+    def history(self,tid,size=1):
+        # This caters for storages which still accept
+        # a version parameter.
+        return self.storage.history(tid,size=size)
+
     def _check_tid(self, tid, exc=None):
         if self.read_only:
             raise ReadOnlyError()
@@ -1379,7 +1383,7 @@
     def history(self, oid, version, size=1):
         if version:
             raise ValueError("Versions aren't supported.")
-        return self.storage.history(oid, size)
+        return self.storage.history(oid, size=size)
 
     def getInvalidations(self, tid):
         result = self.storage.getInvalidations(tid)

Modified: ZODB/branches/3.9/src/ZEO/tests/testConversionSupport.py
===================================================================
--- ZODB/branches/3.9/src/ZEO/tests/testConversionSupport.py	2009-11-20 10:29:28 UTC (rev 105901)
+++ ZODB/branches/3.9/src/ZEO/tests/testConversionSupport.py	2009-11-20 10:37:28 UTC (rev 105902)
@@ -91,8 +91,8 @@
 
 The client simply delegates record_iternext calls to it's server stub.
 
-There's really no decent way to test ZEO without running to muc crazy
-stuff.  I'd rather to a lame test than a really lame test, so here goes.
+There's really no decent way to test ZEO without running too much crazy
+stuff.  I'd rather do a lame test than a really lame test, so here goes.
 
 First, fake out the connection manager so we can make a connection:
 
@@ -108,7 +108,7 @@
     >>> client = ClientStorage('', wait=False)
     >>> ClientStorage.ConnectionManagerClass = oldConnectionManagerClass
 
-Now we'll have our way with it's provate _server attr:
+Now we'll have our way with it's private _server attr:
 
     >>> client._server = FakeStorage()
     >>> next = None
@@ -129,8 +129,8 @@
 
 The server stub simply delegates record_iternext calls to it's rpc.
 
-There's really no decent way to test ZEO without running to muc crazy
-stuff.  I'd rather to a lame test than a really lame test, so here goes.
+There's really no decent way to test ZEO without running to much crazy
+stuff.  I'd rather do a lame test than a really lame test, so here goes.
 
     >>> class FauxRPC:
     ...     storage = FakeStorage()
@@ -153,6 +153,41 @@
 
 """
     
+def history_to_version_compatible_storage():
+    """
+    Some storages work under ZODB <= 3.8 and ZODB >= 3.9.
+    This means they have a history method that accepts a version parameter:
+
+    >>> class VersionCompatibleStorage(FakeStorageBase):
+    ...   def history(self,oid,version='',size=1):
+    ...     return oid,version,size
+
+    A ZEOStorage such as the following should support this type of storage:
+    
+    >>> class OurFakeServer(FakeServer):
+    ...   storages = {'1':VersionCompatibleStorage()}
+    >>> import ZEO.StorageServer
+    >>> zeo = ZEO.StorageServer.ZEOStorage(OurFakeServer(), False)
+    >>> zeo.register('1', False)
+
+    The ZEOStorage should sort out the following call such that the storage gets
+    the correct parameters and so should return the parameters it was called with:
+
+    >>> zeo.history('oid',99)
+    ('oid', '', 99)
+
+    The same problem occurs when a Z308 client connects to a Z309 server,
+    but different code is executed:
+
+    >>> from ZEO.StorageServer import ZEOStorage308Adapter
+    >>> zeo = ZEOStorage308Adapter(VersionCompatibleStorage())
+    
+    The history method should still return the parameters it was called with:
+
+    >>> zeo.history('oid','',99)
+    ('oid', '', 99)
+    """
+
 def test_suite():
     return doctest.DocTestSuite()
 



More information about the Zodb-checkins mailing list