[Zodb-checkins] SVN: ZODB/branches/hannosch-pickle-protocol2/ Make the pickle protocol used by the file storage configurable

Hanno Schlichting hannosch at hannosch.eu
Sat May 1 09:25:11 EDT 2010


Log message for revision 111822:
  Make the pickle protocol used by the file storage configurable
  

Changed:
  U   ZODB/branches/hannosch-pickle-protocol2/etc/sample.conf
  U   ZODB/branches/hannosch-pickle-protocol2/etc/zeo.conf
  U   ZODB/branches/hannosch-pickle-protocol2/etc/zeo.conf.in
  U   ZODB/branches/hannosch-pickle-protocol2/src/ZODB/Connection.py
  U   ZODB/branches/hannosch-pickle-protocol2/src/ZODB/FileStorage/FileStorage.py
  U   ZODB/branches/hannosch-pickle-protocol2/src/ZODB/component.xml
  U   ZODB/branches/hannosch-pickle-protocol2/src/ZODB/config.py
  U   ZODB/branches/hannosch-pickle-protocol2/src/ZODB/serialize.py

-=-
Modified: ZODB/branches/hannosch-pickle-protocol2/etc/sample.conf
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/etc/sample.conf	2010-05-01 12:58:04 UTC (rev 111821)
+++ ZODB/branches/hannosch-pickle-protocol2/etc/sample.conf	2010-05-01 13:25:11 UTC (rev 111822)
@@ -10,58 +10,73 @@
 # against.
 %define host 127.0.0.1
 
-# This storage can only be tested with a concurrency level of 1.
-<zodb fs>
+# These storages can only be tested with a concurrency level of 1.
+
+<zodb fs_p0>
     <filestorage>
-        path var/Data2.fs
+        path var/Data_p1.fs
+        pickle-protocol 0
     </filestorage>
 </zodb>
 
-<zodb zeo_p0>
-    <zeoclient>
-        server $host:8100
-        pickle-protocol 0
-    </zeoclient>
+<zodb fs_p1>
+    <filestorage>
+        path var/Data_p1.fs
+    </filestorage>
 </zodb>
 
-<zodb zeo_p1>
-    <zeoclient>
-        server $host:8100
-    </zeoclient>
-</zodb>
-
-<zodb zeo_p2>
-    <zeoclient>
-        server $host:8100
+<zodb fs_p2>
+    <filestorage>
+        path var/Data_p2.fs
         pickle-protocol 2
-    </zeoclient>
+    </filestorage>
 </zodb>
 
-<zodb zeo_pcache_p0>
-    <zeoclient>
-        server $host:8100
-        client 0
-        var var
-        cache-size 200000000
-        pickle-protocol 0
-    </zeoclient>
-</zodb>
-
-<zodb zeo_pcache_p1>
-    <zeoclient>
-        server $host:8100
-        client 1
-        var var
-        cache-size 200000000
-    </zeoclient>
-</zodb>
-
-<zodb zeo_pcache_p2>
-    <zeoclient>
-        server $host:8100
-        client 2
-        var var
-        cache-size 200000000
-        pickle-protocol 2
-    </zeoclient>
-</zodb>
+# <zodb zeo_p0>
+#     <zeoclient>
+#         server $host:8100
+#         pickle-protocol 0
+#     </zeoclient>
+# </zodb>
+# 
+# <zodb zeo_p1>
+#     <zeoclient>
+#         server $host:8100
+#     </zeoclient>
+# </zodb>
+# 
+# <zodb zeo_p2>
+#     <zeoclient>
+#         server $host:8100
+#         pickle-protocol 2
+#     </zeoclient>
+# </zodb>
+# 
+# <zodb zeo_pcache_p0>
+#     <zeoclient>
+#         server $host:8100
+#         client 0
+#         var var
+#         cache-size 200000000
+#         pickle-protocol 0
+#     </zeoclient>
+# </zodb>
+# 
+# <zodb zeo_pcache_p1>
+#     <zeoclient>
+#         server $host:8100
+#         client 1
+#         var var
+#         cache-size 200000000
+#     </zeoclient>
+# </zodb>
+# 
+# <zodb zeo_pcache_p2>
+#     <zeoclient>
+#         server $host:8100
+#         client 2
+#         var var
+#         cache-size 200000000
+#         pickle-protocol 2
+#     </zeoclient>
+# </zodb>

Modified: ZODB/branches/hannosch-pickle-protocol2/etc/zeo.conf
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/etc/zeo.conf	2010-05-01 12:58:04 UTC (rev 111821)
+++ ZODB/branches/hannosch-pickle-protocol2/etc/zeo.conf	2010-05-01 13:25:11 UTC (rev 111822)
@@ -8,5 +8,5 @@
 </zeo>
 
 <filestorage 1>
-  path /opt/Dropbox/Development/zope/zodb-pickle2/var/Data.fs
+  path /opt/Dropbox/Development/zope/zodb-pickle2/var/Data_zeo.fs
 </filestorage>

Modified: ZODB/branches/hannosch-pickle-protocol2/etc/zeo.conf.in
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/etc/zeo.conf.in	2010-05-01 12:58:04 UTC (rev 111821)
+++ ZODB/branches/hannosch-pickle-protocol2/etc/zeo.conf.in	2010-05-01 13:25:11 UTC (rev 111822)
@@ -8,5 +8,5 @@
 </zeo>
 
 <filestorage 1>
-  path ${buildout:directory}/var/Data.fs
+  path ${buildout:directory}/var/Data_zeo.fs
 </filestorage>

Modified: ZODB/branches/hannosch-pickle-protocol2/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/src/ZODB/Connection.py	2010-05-01 12:58:04 UTC (rev 111821)
+++ ZODB/branches/hannosch-pickle-protocol2/src/ZODB/Connection.py	2010-05-01 13:25:11 UTC (rev 111822)
@@ -106,6 +106,7 @@
         self._normal_storage = self._storage = storage
         self.new_oid = db.new_oid
         self._savepoint_storage = None
+        self._pickle_protocol = getattr(storage, '_pickle_protocol', 1)
 
         # Do we need to join a txn manager?
         self._needs_to_join = True
@@ -597,10 +598,12 @@
                 # changed and registered.
                 continue
 
-            self._store_objects(ObjectWriter(obj), transaction)
+            self._store_objects(ObjectWriter(
+                obj, pickle_protocol=self._pickle_protocol), transaction)
 
         for obj in self._added_during_commit:
-            self._store_objects(ObjectWriter(obj), transaction)
+            self._store_objects(ObjectWriter(
+                obj, pickle_protocol=self._pickle_protocol), transaction)
         self._added_during_commit = None
 
     def _store_objects(self, writer, transaction):

Modified: ZODB/branches/hannosch-pickle-protocol2/src/ZODB/FileStorage/FileStorage.py
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/src/ZODB/FileStorage/FileStorage.py	2010-05-01 12:58:04 UTC (rev 111821)
+++ ZODB/branches/hannosch-pickle-protocol2/src/ZODB/FileStorage/FileStorage.py	2010-05-01 13:25:11 UTC (rev 111822)
@@ -108,7 +108,7 @@
 
     def __init__(self, file_name, create=False, read_only=False, stop=None,
                  quota=None, pack_gc=True, pack_keep_old=True, packer=None,
-                 blob_dir=None):
+                 blob_dir=None, pickle_protocol=1):
 
         if read_only:
             self._is_read_only = True
@@ -136,6 +136,8 @@
         if packer is not None:
             self.packer = packer
 
+        self._pickle_protocol = pickle_protocol
+
         BaseStorage.BaseStorage.__init__(self, file_name)
 
         index, tindex = self._newIndexes()

Modified: ZODB/branches/hannosch-pickle-protocol2/src/ZODB/component.xml
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/src/ZODB/component.xml	2010-05-01 12:58:04 UTC (rev 111821)
+++ ZODB/branches/hannosch-pickle-protocol2/src/ZODB/component.xml	2010-05-01 13:25:11 UTC (rev 111822)
@@ -65,6 +65,11 @@
          ".old" file.
       </description>
     </key>
+    <key name="pickle-protocol" required="no" datatype="integer" default="1">
+      <description>
+        The pickle protocol used for the storage. Defaults to 1.
+      </description>
+    </key>
   </sectiontype>
 
   <sectiontype name="mappingstorage" datatype=".MappingStorage"
@@ -138,7 +143,7 @@
         The maximum size of the client cache, in bytes, KB or MB.
       </description>
     </key>
-    <key name="pickle-protocol" required="no" datatype="integer">
+    <key name="pickle-protocol" required="no" datatype="integer" default="1">
       <description>
         The pickle protocol used for the client. Defaults to 1.
       </description>

Modified: ZODB/branches/hannosch-pickle-protocol2/src/ZODB/config.py
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/src/ZODB/config.py	2010-05-01 12:58:04 UTC (rev 111821)
+++ ZODB/branches/hannosch-pickle-protocol2/src/ZODB/config.py	2010-05-01 13:25:11 UTC (rev 111822)
@@ -161,7 +161,7 @@
             options['packer'] = getattr(__import__(m, {}, {}, ['*']), name)
 
         for name in ('blob_dir', 'create', 'read_only', 'quota', 'pack_gc',
-                     'pack_keep_old'):
+                     'pack_keep_old', 'pickle_protocol'):
             v = getattr(config, name, self)
             if v is not self:
                 options[name] = v

Modified: ZODB/branches/hannosch-pickle-protocol2/src/ZODB/serialize.py
===================================================================
--- ZODB/branches/hannosch-pickle-protocol2/src/ZODB/serialize.py	2010-05-01 12:58:04 UTC (rev 111821)
+++ ZODB/branches/hannosch-pickle-protocol2/src/ZODB/serialize.py	2010-05-01 13:25:11 UTC (rev 111822)
@@ -171,9 +171,9 @@
 
     _jar = None
 
-    def __init__(self, obj=None):
+    def __init__(self, obj=None, pickle_protocol=1):
         self._file = cStringIO.StringIO()
-        self._p = cPickle.Pickler(self._file, 1)
+        self._p = cPickle.Pickler(self._file, pickle_protocol)
         self._p.inst_persistent_id = self.persistent_id
         self._stack = []
         if obj is not None:



More information about the Zodb-checkins mailing list