[Zodb-checkins] SVN: ZODB/branches/jim-zeo-blob/src/ZEO/zrpc/connection.py Updated the ZEO protocol to reflect the new Blob methods.

Jim Fulton jim at zope.com
Tue May 15 18:43:51 EDT 2007


Log message for revision 75785:
  Updated the ZEO protocol to reflect the new Blob methods.
  
  Factored msgid allocation out of send_call and __call_message.
  

Changed:
  U   ZODB/branches/jim-zeo-blob/src/ZEO/zrpc/connection.py

-=-
Modified: ZODB/branches/jim-zeo-blob/src/ZEO/zrpc/connection.py
===================================================================
--- ZODB/branches/jim-zeo-blob/src/ZEO/zrpc/connection.py	2007-05-15 22:43:47 UTC (rev 75784)
+++ ZODB/branches/jim-zeo-blob/src/ZEO/zrpc/connection.py	2007-05-15 22:43:49 UTC (rev 75785)
@@ -295,17 +295,20 @@
     # Z303 -- named after the ZODB release 3.3
     #         Added methods for MVCC:
     #             loadBefore()
-    #             loadEx()
     #         A Z303 client cannot talk to a Z201 server, because the latter
     #         doesn't support MVCC.  A Z201 client can talk to a Z303 server,
     #         but because (at least) the type of the root object changed
     #         from ZODB.PersistentMapping to persistent.mapping, the older
     #         client can't actually make progress if a Z303 client created,
     #         or ever modified, the root.
+    #
+    # Z308 -- named after the ZODB release 3.8
+    #         Added methods for MVCC:
+    # XXX add blob methods
 
     # Protocol variables:
     # Our preferred protocol.
-    current_protocol = "Z303"
+    current_protocol = "Z308"
 
     # If we're a client, an exhaustive list of the server protocols we
     # can accept.
@@ -313,7 +316,7 @@
 
     # If we're a server, an exhaustive list of the client protocols we
     # can accept.
-    clients_we_can_talk_to = ["Z200", "Z201", current_protocol]
+    clients_we_can_talk_to = ["Z200", "Z201", "Z303", current_protocol]
 
     # This is pretty excruciating.  Details:
     #
@@ -619,17 +622,29 @@
     # The next two public methods (call and callAsync) are used by
     # clients to invoke methods on remote objects
 
-    def send_call(self, method, args, flags):
-        # send a message and return its msgid
+    def __new_msgid(self):
         self.msgid_lock.acquire()
         try:
             msgid = self.msgid
             self.msgid = self.msgid + 1
+            return msgid
         finally:
             self.msgid_lock.release()
+
+    def __call_message(self, method, args, flags):
+        # compute a message and return it
+        msgid = self.__new_msgid()
         if __debug__:
             self.log("send msg: %d, %d, %s, ..." % (msgid, flags, method),
                      level=TRACE)
+        return self.marshal.encode(msgid, flags, method, args)
+
+    def send_call(self, method, args, flags):
+        # send a message and return its msgid
+        msgid = self.__new_msgid()
+        if __debug__:
+            self.log("send msg: %d, %d, %s, ..." % (msgid, flags, method),
+                     level=TRACE)
         buf = self.marshal.encode(msgid, flags, method, args)
         self.message_output(buf)
         return msgid
@@ -684,6 +699,18 @@
             raise DisconnectedError()
         self.send_call(method, args, ASYNC)
 
+    def callAsyncIterator(self, iterator):
+        """Queue a sequence of calls using an iterator
+
+        The calls will not be interleaved with other calls from the same
+        client.
+        """
+        self.message_output(self.__outputIterator(iterator))
+
+    def __outputIterator(self, iterator):
+        for method, args in iterator:
+            yield self.__call_message(method, args, ASYNC)
+
     # handle IO, possibly in async mode
 
     def _prepare_async(self):



More information about the Zodb-checkins mailing list