SVN: ZODB/branches/hannosch-pickle-protocol2/ Generalize the option as pickle-protocol and also use it for the transaction buffer

Hanno Schlichting <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <20100501120057.89854941B7__9656.47587222538$1272715263$gmane$org@cvs.zope.org>
Log message for revision 111818:
  Generalize the option as pickle-protocol and also use it for the transaction buffer
  

Changed:
  U   ZODB/branches/hannosch-pickle-protocol2/etc/sample.conf
  U   ZODB/branches/hannosch-pickle-protocol2/src/ZEO/ClientStorage.py
  U   ZODB/branches/hannosch-pickle-protocol2/src/ZEO/TransactionBuffer.py
  U   ZODB/branches/hannosch-pickle-protocol2/src/ZODB/component.xml
  U   ZODB/branches/hannosch-pickle-protocol2/src/ZODB/config.py

-=-
Modified: ZODB/branches/hannosch-pickle-protocol2/etc/sample.conf
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/etc/sample.conf	2010-05-01 11:51:50 UTC (rev 111817)
+++ ZODB/branches/hannosch-pickle-protocol2/etc/sample.conf	2010-05-01 12:00:57 UTC (rev 111818)
@@ -38,6 +38,6 @@
         client 1
         var var
         cache-size 200000000
-        cache-protocol 2
+        pickle-protocol 2
     </zeoclient>
 </zodb>

Modified: ZODB/branches/hannosch-pickle-protocol2/src/ZEO/ClientStorage.py
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/src/ZEO/ClientStorage.py	2010-05-01 11:51:50 UTC (rev 111817)
+++ ZODB/branches/hannosch-pickle-protocol2/src/ZEO/ClientStorage.py	2010-05-01 12:00:57 UTC (rev 111818)
@@ -123,7 +123,7 @@
                  username='', password='', realm=None,
                  blob_dir=None, shared_blob_dir=False,
                  blob_cache_size=None, blob_cache_size_check=10,
-                 cache_protocol=1,
+                 pickle_protocol=1,
                  ):
         """ClientStorage constructor.
 
@@ -235,8 +235,8 @@
             loaded into the cache. Defaults to 10% of the blob cache
             size.   This option is ignored if shared_blob_dir is true.
 
-        cache_protocol
-            The pickle protocol used for the ZEO cache. Defaults to 1.
+        pickle_protocol
+            The pickle protocol used for the client. Defaults to 1.
 
         Note that the authentication protocol is defined by the server
         and is detected by the ClientStorage upon connecting (see
@@ -322,11 +322,13 @@
         self._server_addr = None
 
         self._pickler = self._tfile = None
+        self._pickle_protocol = pickle_protocol
 
         self._info = {'length': 0, 'size': 0, 'name': 'ZEO Client',
                       'supportsUndo': 0, 'interfaces': ()}
 
-        self._tbuf = self.TransactionBufferClass()
+        self._tbuf = self.TransactionBufferClass(
+            pickle_protocol=pickle_protocol)
         self._db = None
         self._ltid = None # the last committed transaction
 
@@ -400,7 +402,6 @@
             cache_path = None
 
         self._cache = self.ClientCacheClass(cache_path, size=cache_size)
-        self._cache_protocol = cache_protocol
 
         self._blob_cache_size = blob_cache_size
         self._blob_data_bytes_loaded = 0
@@ -1303,7 +1304,7 @@
         # setup tempfile to hold zeoVerify results and interim
         # invalidation results
         self._tfile = tempfile.TemporaryFile(suffix=".inv")
-        self._pickler = cPickle.Pickler(self._tfile, self._cache_protocol)
+        self._pickler = cPickle.Pickler(self._tfile, self._pickle_protocol)
         self._pickler.fast = 1 # Don't use the memo
 
         if self._connection.peer_protocol_version < 'Z309':

Modified: ZODB/branches/hannosch-pickle-protocol2/src/ZEO/TransactionBuffer.py
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/src/ZEO/TransactionBuffer.py	2010-05-01 11:51:50 UTC (rev 111817)
+++ ZODB/branches/hannosch-pickle-protocol2/src/ZEO/TransactionBuffer.py	2010-05-01 12:00:57 UTC (rev 111818)
@@ -55,7 +55,7 @@
     # inconsistent data.  This should have minimal effect, though,
     # because the Connection is connected to a closed storage.
 
-    def __init__(self):
+    def __init__(self, pickle_protocol=1):
         self.file = tempfile.TemporaryFile(suffix=".tbuf")
         self.lock = Lock()
         self.closed = 0
@@ -64,7 +64,8 @@
         self.blobs = []
         # It's safe to use a fast pickler because the only objects
         # stored are builtin types -- strings or None.
-        self.pickler = cPickle.Pickler(self.file, 1)
+        self.pickle_protocol = pickle_protocol
+        self.pickler = cPickle.Pickler(self.file, pickle_protocol)
         self.pickler.fast = 1
 
     def close(self):

Modified: ZODB/branches/hannosch-pickle-protocol2/src/ZODB/component.xml
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/src/ZODB/component.xml	2010-05-01 11:51:50 UTC (rev 111817)
+++ ZODB/branches/hannosch-pickle-protocol2/src/ZODB/component.xml	2010-05-01 12:00:57 UTC (rev 111818)
@@ -138,9 +138,9 @@
         The maximum size of the client cache, in bytes, KB or MB.
       </description>
     </key>
-    <key name="cache-protocol" required="no" datatype="integer">
+    <key name="pickle-protocol" required="no" datatype="integer">
       <description>
-        The pickle protocol used for the cache. Defaults to 1.
+        The pickle protocol used for the client. Defaults to 1.
       </description>
     </key>
     <key name="name" default="">

Modified: ZODB/branches/hannosch-pickle-protocol2/src/ZODB/config.py
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/src/ZODB/config.py	2010-05-01 11:51:50 UTC (rev 111817)
+++ ZODB/branches/hannosch-pickle-protocol2/src/ZODB/config.py	2010-05-01 12:00:57 UTC (rev 111818)
@@ -188,8 +188,8 @@
             options['blob_cache_size'] = self.config.blob_cache_size
         if self.config.blob_cache_size_check is not None:
             options['blob_cache_size_check'] = self.config.blob_cache_size_check
-        if self.config.cache_protocol is not None:
-            options['cache_protocol'] = self.config.cache_protocol
+        if self.config.pickle_protocol is not None:
+            options['pickle_protocol'] = self.config.pickle_protocol
 
         return ClientStorage(
             L,
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.