[Zodb-checkins] SVN: ZODB/branches/jim-zeo-blob/src/ZEO/zrpc/smac.py Added a comment explaining the elegent hack. :)

Jim Fulton jim at zope.com
Thu May 17 16:39:41 EDT 2007


Log message for revision 75819:
  Added a comment explaining the elegent hack. :)
  

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

-=-
Modified: ZODB/branches/jim-zeo-blob/src/ZEO/zrpc/smac.py
===================================================================
--- ZODB/branches/jim-zeo-blob/src/ZEO/zrpc/smac.py	2007-05-17 20:39:31 UTC (rev 75818)
+++ ZODB/branches/jim-zeo-blob/src/ZEO/zrpc/smac.py	2007-05-17 20:39:40 UTC (rev 75819)
@@ -129,6 +129,23 @@
 
     def setSessionKey(self, sesskey):
         log("set session key %r" % sesskey)
+
+        # Low-level construction is now delayed until data are sent.
+        # This is to allow use of iterators that generate messages
+        # only when we're ready to do I/O so that we can effeciently
+        # transmit large files.  Because we delay messages, we also
+        # have to delay setting the session key to retain proper
+        # ordering.
+
+        # The low-level output queue supports strings, a special close
+        # marker, and iterators.  It doesn't support callbacks.  We
+        # can create a allback by providing an iterator that doesn't
+        # yield anything.
+
+        # The hack fucntion below is a callback in iterator's
+        # clothing. :)  It never yields anything, but is a generator
+        # and thus iterator, because it contains a yield statement.
+
         def hack():
             self.__hmac_send = hmac.HMAC(sesskey, digestmod=sha)
             self.__hmac_recv = hmac.HMAC(sesskey, digestmod=sha)



More information about the Zodb-checkins mailing list