[Zope3-checkins] CVS: ZODB4/src/zodb/zeo - server.py:1.6.4.1

Barry Warsaw barry@wooz.org
Mon, 10 Feb 2003 18:25:27 -0500


Update of /cvs-repository/ZODB4/src/zodb/zeo
In directory cvs.zope.org:/tmp/cvs-serv9080/src/zodb/zeo

Modified Files:
      Tag: opaque-pickles-branch
	server.py 
Log Message:
The start of opaque pickles (from the p.o.v. of the storages).  This
will eventually allow us to pass compressed pickles to the storage if
we want.

The approach basically changes store() so that the data argument is a
2-tuple of the pickle and the list of oids referenced in the pickle.
This is the first step in the changes, but currently, only Berkeley
storages natively store the refs included in the store() API call.

Changes here include:

- store(): kludge to make zeo work for now; if data is a string,
  re-tuplify it by calling findrefs().  The XXX comment states the
  obvious -- the protocol needs to be extended.


=== ZODB4/src/zodb/zeo/server.py 1.6 => 1.6.4.1 ===
--- ZODB4/src/zodb/zeo/server.py:1.6	Wed Feb  5 18:28:24 2003
+++ ZODB4/src/zodb/zeo/server.py	Mon Feb 10 18:25:26 2003
@@ -33,8 +33,9 @@
 from zodb.zeo.zrpc.server import Dispatcher
 from zodb.zeo.zrpc.connection import ManagedServerConnection, Delay, MTDelay
 
+from zodb.serialize import findrefs
 from zodb.ztransaction import Transaction
-from zodb.interfaces import TransactionError
+from zodb.interfaces import TransactionError, ZERO
 from zodb.storage.interfaces import *
 
 from zope.interface.implements import objectImplements
@@ -624,6 +625,9 @@
         self.storage.tpcAbort(self.txn)
 
     def store(self, oid, serial, data, version):
+        # XXX zrpc needs to know that data is a 2-tuple (data, refs)
+        if isinstance(data, str):
+            data = data, findrefs(data)
         try:
             newserial = self.storage.store(oid, serial, data, version,
                                            self.txn)
@@ -648,7 +652,7 @@
             # The exception is reported back as newserial for this oid
             newserial = err
         else:
-            if serial != "\0\0\0\0\0\0\0\0":
+            if serial != ZERO:
                 self.invalidated.append((oid, version))
         self.serials.append((oid, newserial))