[Zodb-checkins] SVN: ZODB/branches/3.9/src/ Bugs Fixed

Jim Fulton jim at zope.com
Mon Sep 20 16:41:20 EDT 2010


Log message for revision 116688:
  Bugs Fixed
  - ZEO extension methods failed when a client reconnected to a
    storage. (https://bugs.launchpad.net/zodb/+bug/143344)
  

Changed:
  U   ZODB/branches/3.9/src/CHANGES.txt
  U   ZODB/branches/3.9/src/ZEO/ClientStorage.py
  U   ZODB/branches/3.9/src/ZEO/tests/testZEO.py
  U   ZODB/branches/3.9/src/ZODB/FileStorage/FileStorage.py

-=-
Modified: ZODB/branches/3.9/src/CHANGES.txt
===================================================================
--- ZODB/branches/3.9/src/CHANGES.txt	2010-09-20 20:17:10 UTC (rev 116687)
+++ ZODB/branches/3.9/src/CHANGES.txt	2010-09-20 20:41:19 UTC (rev 116688)
@@ -39,6 +39,9 @@
   The objects' _p_oid and _p_jar variables weren't cleared, leading to
   surprizing errors.
 
+- ZEO extension methods failed when a client reconnected to a
+  storage. (https://bugs.launchpad.net/zodb/+bug/143344)
+
 - On Mac OS X, clients that connected and disconnected quickly could
   cause a ZEO server to stop accepting connections, due to a failure
   to catch errors in the initial part of the connection process.

Modified: ZODB/branches/3.9/src/ZEO/ClientStorage.py
===================================================================
--- ZODB/branches/3.9/src/ZEO/ClientStorage.py	2010-09-20 20:17:10 UTC (rev 116687)
+++ ZODB/branches/3.9/src/ZEO/ClientStorage.py	2010-09-20 20:41:19 UTC (rev 116688)
@@ -644,7 +644,10 @@
     def _handle_extensions(self):
         for name in self.getExtensionMethods().keys():
             if not hasattr(self, name):
-                setattr(self, name, self._server.extensionMethod(name))
+                def mklambda(mname):
+                    return (lambda *args, **kw:
+                            self._server.rpc.call(mname, *args, **kw))
+                setattr(self, name, mklambda(name))
 
     def set_server_addr(self, addr):
         # Normalize server address and convert to string

Modified: ZODB/branches/3.9/src/ZEO/tests/testZEO.py
===================================================================
--- ZODB/branches/3.9/src/ZEO/tests/testZEO.py	2010-09-20 20:17:10 UTC (rev 116687)
+++ ZODB/branches/3.9/src/ZEO/tests/testZEO.py	2010-09-20 20:41:19 UTC (rev 116688)
@@ -1352,7 +1352,31 @@
 
     """
 
+def lp143344_extension_methods_not_lost_on_server_restart():
+    r"""
+Make sure we don't lose exension methods on server restart.
 
+    >>> addr, adminaddr = start_server(keep=True)
+    >>> conn = ZEO.connection(addr)
+    >>> conn.root.x = 1
+    >>> transaction.commit()
+    >>> conn.db().storage.answer_to_the_ultimate_question()
+    42
+
+    >>> stop_server(adminaddr)
+    >>> forker.wait_until('not connected',
+    ...            lambda : not conn.db().storage.is_connected())
+    >>> _ = start_server(addr=addr)
+    >>> forker.wait_until('connected', conn.db().storage.is_connected)
+
+    >>> conn.root.x
+    1
+    >>> conn.db().storage.answer_to_the_ultimate_question()
+    42
+
+    >>> conn.close()
+    """
+
 slow_test_classes = [
     BlobAdaptedFileStorageTests, BlobWritableCacheTests,
     DemoStorageTests, FileStorageTests, MappingStorageTests,

Modified: ZODB/branches/3.9/src/ZODB/FileStorage/FileStorage.py
===================================================================
--- ZODB/branches/3.9/src/ZODB/FileStorage/FileStorage.py	2010-09-20 20:17:10 UTC (rev 116687)
+++ ZODB/branches/3.9/src/ZODB/FileStorage/FileStorage.py	2010-09-20 20:41:19 UTC (rev 116688)
@@ -1331,7 +1331,15 @@
 
         return oid, tid, data, next_oid
 
+    ######################################################################
+    # The following 2 methods are for testing a ZEO extension mechanism
+    def getExtensionMethods(self):
+        return dict(answer_to_the_ultimate_question=None)
 
+    def answer_to_the_ultimate_question(self):
+        return 42
+    #
+    ######################################################################
 
 def shift_transactions_forward(index, tindex, file, pos, opos):
     """Copy transactions forward in the data file



More information about the Zodb-checkins mailing list