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

Jeremy Hylton jeremy@zope.com
Thu, 10 Jan 2002 01:11:30 -0500


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

Modified Files:
      Tag: ZEO-ZRPC-Dev
	StorageServer.py 
Log Message:
Fix raise of ReadOnlyError; don't include module name.


=== StandaloneZODB/ZEO/StorageServer.py 1.21.4.18 => 1.21.4.19 ===
 from zrpc2 import Dispatcher, Handler, ManagedServerConnection, Delay
 from ZODB.POSException import StorageError, StorageTransactionError, \
-     TransactionError
+     TransactionError, ReadOnlyError
 from ZODB.referencesf import referencesf
 from ZODB.Transaction import Transaction
 
@@ -122,9 +122,11 @@
     pass
 
 class StorageServer:
-    def __init__(self, addr, storages):
+    def __init__(self, addr, storages, read_only=0):
+        # XXX should read_only be a per-storage option? not yet...
         self.addr = addr
         self.storages = storages
+        self.read_only = read_only
         self.connections = {}
         for name, store in storages.items():
             fixup_storage(store)
@@ -229,8 +231,8 @@
             self._log("unknown storage_id: %s" % storage_id)
             raise ValueError, "unknown storage: %s" % storage_id
 
-        if not read_only and storage.isReadOnly():
-            raise POSException.ReadOnlyError()
+        if not read_only and (self.server.read_only or storage.isReadOnly()):
+            raise ReadOnlyError()
 
         self.__storage_id = storage_id
         self.__storage = storage