[Zodb-checkins] CVS: StandaloneZODB/ZEO - StorageServer.py:1.32.6.3

Jeremy Hylton jeremy@zope.com
Wed, 16 Jan 2002 20:42:58 -0500


Update of /cvs-repository/StandaloneZODB/ZEO
In directory cvs.zope.org:/tmp/cvs-serv14437

Modified Files:
      Tag: Standby-branch
	StorageServer.py 
Log Message:
Various cleanups.

Rename StorageProxy to ZEOStorage.  The latter seems more consistent
with usage like FileStorage.  It's ZEOStorage because it implements
the storage API exported by the storage server.

Track removal of Handler class in zrpc.connection.

Simplify newConnection() and extend StorageServer to do new
notifyConnected() protocol.

Fiddle some comments.



=== StandaloneZODB/ZEO/StorageServer.py 1.32.6.2 => 1.32.6.3 ===
 from ZEO import ClientStub
 from ZEO.zrpc.server import Dispatcher
-from ZEO.zrpc.connection import ManagedServerConnection, Handler, Delay
+from ZEO.zrpc.connection import ManagedServerConnection, Delay
 
 import zLOG
 from ZODB.POSException import StorageError, StorageTransactionError, \
@@ -132,9 +132,7 @@
                                      reuse_addr=1)
 
     def newConnection(self, sock, addr):
-        # XXX figure out how to do the connection / proxy dance better
-        c = ManagedServerConnection(sock, addr, None, self)
-        c.register_object(StorageProxy(self, c))
+        c = ManagedServerConnection(sock, addr, ZEOStorage(self), self)
         log("new connection %s: %s" % (addr, `c`))
         return c
         
@@ -147,7 +145,8 @@
         if l is None:
             l = self.connections[storage_id] = []
             # intialize waiting list
-            self.storages[storage_id]._StorageProxy__waiting = []
+            # XXX why are we using a mangled name ?!?
+            self.storages[storage_id]._ZEOStorage__waiting = []
         l.append(proxy)
 
     def invalidate(self, conn, storage_id, invalidated=(), info=0):
@@ -172,24 +171,24 @@
                 pass
 
     def close(self, conn):
-        # XXX who calls this?
-        # called when conn is closed
-        # way too inefficient
         removed = 0
         for sid, cl in self.connections.items():
             if conn.obj in cl:
                 cl.remove(conn.obj)
                 removed = 1
 
-class StorageProxy(Handler):
-    def __init__(self, server, conn):
+class ZEOStorage:
+    def __init__(self, server):
         self.server = server
-        self.client = ClientStub.ClientStorage(conn)
+        self.client = None
         self.__storage = None
         self.__storage_id = "uninitialized"
         self.__invalidated = []
         self._transaction = None
 
+    def notifyConnected(self, conn):
+        self.client = ClientStub.ClientStorage(conn)
+        
     def __repr__(self):
         tid = self._transaction and repr(self._transaction.id)
         if self.__storage:
@@ -337,8 +336,9 @@
 
     def storea(self, oid, serial, data, version, id):
         self._check_tid(id, exc=StorageTransactionError)
+        # XXX The try/except seems to be doing a lot of work.  How
+        # worried are we about errors that can't be pickled.
         try:
-            # XXX does this stmt need to be in the try/except?
             newserial = self.__storage.store(oid, serial, data, version,
                                              self._transaction)
         except TransactionError, v: