SVN: ZODB/trunk/src/ Bug fixed:

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <20100910173802.08CB1941E4__35356.4671976075$1284140289$gmane$org@cvs.zope.org>
Log message for revision 116296:
  Bug fixed:
  
  - ZEO extension methods failed when a client reconnected to a
    storage. (https://bugs.launchpad.net/zodb/+bug/143344)
  

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

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-09-10 16:03:27 UTC (rev 116295)
+++ ZODB/trunk/src/CHANGES.txt	2010-09-10 17:38:01 UTC (rev 116296)
@@ -15,6 +15,8 @@
   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)
 
 3.10.0b6 (2010-09-08)
 =====================

Modified: ZODB/trunk/src/ZEO/ClientStorage.py
===================================================================
--- ZODB/trunk/src/ZEO/ClientStorage.py	2010-09-10 16:03:27 UTC (rev 116295)
+++ ZODB/trunk/src/ZEO/ClientStorage.py	2010-09-10 17:38:01 UTC (rev 116296)
@@ -664,7 +664,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/trunk/src/ZEO/tests/testZEO.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/testZEO.py	2010-09-10 16:03:27 UTC (rev 116295)
+++ ZODB/trunk/src/ZEO/tests/testZEO.py	2010-09-10 17:38:01 UTC (rev 116296)
@@ -1568,6 +1568,31 @@
     >>> ZEO.zrpc.client.ConnectThread = ConnectThread
     """
 
+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)
+    >>> wait_until('not connected',
+    ...            lambda : not conn.db().storage.is_connected())
+    >>> _ = start_server(addr=addr)
+    >>> 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,
     MappingStorageTests, DemoStorageTests,

Modified: ZODB/trunk/src/ZODB/FileStorage/FileStorage.py
===================================================================
--- ZODB/trunk/src/ZODB/FileStorage/FileStorage.py	2010-09-10 16:03:27 UTC (rev 116295)
+++ ZODB/trunk/src/ZODB/FileStorage/FileStorage.py	2010-09-10 17:38:01 UTC (rev 116296)
@@ -1275,7 +1275,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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.