[Zodb-checkins] CVS: StandaloneZODB/ZEO - ClientStorage.py:1.26.4.30 StorageServer.py:1.21.4.16

Jeremy Hylton jeremy@zope.com
Mon, 7 Jan 2002 18:07:34 -0500


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

Modified Files:
      Tag: ZEO-ZRPC-Dev
	ClientStorage.py StorageServer.py 
Log Message:
Provisional read-only support for ZEO.

The client does all the necessary checks, but the server should raise
an exception if its storage is read-only and the client requests
read-write.


=== StandaloneZODB/ZEO/ClientStorage.py 1.26.4.29 => 1.26.4.30 ===
 class ClientStorage:
 
-    def __init__(self, addr, storage='1', cache_size=20000000,
-                 name='', client='', debug=0, var=None,
-                 min_disconnect_poll=5, max_disconnect_poll=300,
+    def __init__(self, addr, storage='1', read_only=0,
+                 cache_size=20000000, name='', client='', debug=0,
+                 var=None, min_disconnect_poll=5,
+                 max_disconnect_poll=300,
                  wait_for_server_on_startup=1):
 
         # Decide whether to use non-temporary files
         client = client or os.environ.get('ZEO_CLIENT','')
 
         self._server = disconnected_stub
+        self._is_read_only = read_only
         self._connection = addr
         self._storage = storage
         self._debug = debug
@@ -232,7 +234,7 @@
 
         # XXX Why is this synchronous?  If it were async, verification
         # would start faster.
-        stub.register(str(self._storage))
+        stub.register(str(self._storage), self._is_read_only)
         self.verify_cache(stub)
 
         # Don't make the server available to clients until after
@@ -323,6 +325,8 @@
             self.tpc_cond.release()
 
     def abortVersion(self, src, transaction):
+        if self._is_read_only:
+            raise POSException.ReadOnlyError()
         self._check_trans(transaction,
                           POSException.StorageTransactionError)
         oids = self._server.abortVersion(src, self._serial)
@@ -341,6 +345,8 @@
             self._cache.close()
         
     def commitVersion(self, src, dest, transaction):
+        if self._is_read_only:
+            raise POSException.ReadOnlyError()
         self._check_trans(transaction,
                           POSException.StorageTransactionError)
         oids = self._server.commitVersion(src, dest, self._serial)
@@ -383,6 +389,8 @@
         return self._server.modifiedInVersion(oid)
 
     def new_oid(self, last=None):
+        if self._is_read_only:
+            raise POSException.ReadOnlyError()
         # We want to avoid a situation where multiple oid requests are
         # made at the same time.
         self.oid_cond.acquire()
@@ -395,6 +403,8 @@
         return oid
         
     def pack(self, t=None, rf=None, wait=0, days=0):
+        if self._is_read_only:
+            raise POSException.ReadOnlyError()
         # Note that we ignore the rf argument.  The server
         # will provide it's own implementation.
         if t is None:
@@ -414,6 +424,8 @@
             return r
 
     def store(self, oid, serial, data, version, transaction):
+        if self._is_read_only:
+            raise POSException.ReadOnlyError()
         self._check_trans(transaction, POSException.StorageTransactionError)
         self._server.storea(oid, serial, data, version, self._serial) 
         self._tbuf.store(oid, version, data)
@@ -512,6 +524,8 @@
         self._tbuf.clear()
 
     def transactionalUndo(self, trans_id, trans):
+        if self._is_read_only:
+            raise POSException.ReadOnlyError()
         self._check_trans(trans, POSException.StorageTransactionError)
         oids = self._server.transactionalUndo(trans_id, self._serial)
         for oid in oids:
@@ -519,6 +533,8 @@
         return oids
 
     def undo(self, transaction_id):
+        if self._is_read_only:
+            raise POSException.ReadOnlyError()
         # XXX what are the sync issues here?
         oids = self._server.undo(transaction_id)
         for oid in oids:


=== StandaloneZODB/ZEO/StorageServer.py 1.21.4.15 => 1.21.4.16 ===
         return 1
 
-    def register(self, storage_id):
+    def register(self, storage_id, read_only):
         """Select the storage that this client will use
 
         This method must be the first one called by the client.