[Zodb-checkins] CVS: Zope3/src/zodb - db.py:1.6.4.1 interfaces.py:1.6.4.1 lockfile.py:1.2.8.1

Jeremy Hylton jeremy@zope.com
Tue, 4 Feb 2003 17:54:43 -0500


Update of /cvs-repository/Zope3/src/zodb
In directory cvs.zope.org:/tmp/cvs-serv6570/src/zodb

Modified Files:
      Tag: storage-interface-branch
	db.py interfaces.py lockfile.py 
Log Message:
Refactor storage interfaces.

Move a bunch of exceptions related to storages from zodb.interfaces to
zodb.storages.interfaces.

Add __implements__ statements in all the concrete storage classes.

Add a simple (good?) mechanism to propagate __implements__ values from
a ZEO storage to its clients.

Remove all use of supportsXXX() methods in favor of
ISomeInterface.isImplementedBy().


=== Zope3/src/zodb/db.py 1.6 => 1.6.4.1 ===
--- Zope3/src/zodb/db.py:1.6	Tue Feb  4 05:32:46 2003
+++ Zope3/src/zodb/db.py	Tue Feb  4 17:54:09 2003
@@ -24,7 +24,7 @@
 from types import StringType
 import logging
 
-from zodb.interfaces import StorageError, StorageVersionError
+from zodb.storage.interfaces import *
 from zodb.connection import Connection
 from zodb.serialize import getDBRoot
 from zodb.ztransaction import Transaction
@@ -88,9 +88,12 @@
             storage.tpc_finish(t)
 
         # Pass through methods:
-        for m in ('supportsVersions', 'undoInfo', 'versionEmpty',
-                  'versions', 'modifiedInVersion', 'versionEmpty'):
-            setattr(self, m, getattr(storage, m))
+        if IUndoStorage.isImplementedBy(storage):
+            self.undoInfo = storage.undoInfo
+        if IVersionStorage.isImplementedBy(storage):
+            for m in ['versionEmpty', 'versions', 'modifiedInVersion',
+                      'versionEmpty']:
+                setattr(self, m, getattr(storage, m))
 
     def _checkVersion(self):
         # Make sure the database version that created the storage is


=== Zope3/src/zodb/interfaces.py 1.6 => 1.6.4.1 ===
--- Zope3/src/zodb/interfaces.py:1.6	Tue Jan 28 13:17:30 2003
+++ Zope3/src/zodb/interfaces.py	Tue Feb  4 17:54:09 2003
@@ -25,6 +25,26 @@
 from transaction.interfaces \
      import TransactionError, RollbackError, ConflictError as _ConflictError
 
+__all__ = ['POSError',
+           'POSKeyError',
+           'ConflictError',
+           'ReadConflictError',
+           'DanglingReferenceError',
+           'VersionError',
+           'VersionCommitError',
+           'VersionLockError',
+           'UndoError',
+           'MultipleUndoErrors',
+           'ExportError',
+           'Unsupported',
+           
+           'InvalidObjectReference',
+           'IAppConnection',
+           'IConnection',
+           'ITransaction',
+           'ITransactionAttrs',
+           ]
+
 def _fmt_oid(oid):
     return "%016x" % zodb.utils.u64(oid)
 
@@ -183,37 +203,6 @@
 
     def __str__(self):
         return "\n".join([_fmt_undo(*pair) for pair in self._errs])
-
-class StorageError(POSError):
-    """Base class for storage based exceptions."""
-
-class StorageVersionError(StorageError):
-    """The storage version doesn't match the database version."""
-
-    def __init__(self, db_ver, storage_ver):
-        self.db_ver = db_ver
-        self.storage_ver = storage_ver
-
-    def __str__(self):
-        db = ".".join(self.db_ver)
-        storage = ".".join(self.storage_ver)
-        return ("Storage version %s passed to database version %s"
-                % (storage, db))
-
-class StorageTransactionError(StorageError):
-    """An operation was invoked for an invalid transaction or state."""
-
-class StorageSystemError(StorageError):
-    """Panic! Internal storage error!"""
-
-class MountedStorageError(StorageError):
-    """Unable to access mounted storage."""
-
-class ReadOnlyError(StorageError):
-    """Unable to modify objects in a read-only storage."""
-
-class TransactionTooLargeError(StorageTransactionError):
-    """The transaction exhausted some finite storage resource."""
 
 class ExportError(POSError):
     """An export file doesn't have the right format."""


=== Zope3/src/zodb/lockfile.py 1.2 => 1.2.8.1 ===
--- Zope3/src/zodb/lockfile.py:1.2	Wed Dec 25 09:12:16 2002
+++ Zope3/src/zodb/lockfile.py	Tue Feb  4 17:54:09 2003
@@ -12,7 +12,7 @@
 #
 ##############################################################################
 
-from zodb.interfaces import StorageSystemError
+from zodb.storage.interfaces import StorageSystemError
 
 # Try to create a function that creates Unix file locks.
 try: