[Zope3-checkins] CVS: Zope3/lib/python/ZODB - interfaces.py:1.3 ZTransaction.py:1.5 BaseStorage.py:1.27

Jeremy Hylton jeremy@zope.com
Sat, 21 Dec 2002 08:21:29 -0500


Update of /cvs-repository/Zope3/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv15476/lib/python/ZODB

Modified Files:
	interfaces.py ZTransaction.py BaseStorage.py 
Log Message:
Split ZODB's ITransaction into two parts.

The first part is the client interface with methods like note().
The second part is the internal transaction/storage interface with
attributes like description.

Should resolve collector issue 16


=== Zope3/lib/python/ZODB/interfaces.py 1.2 => 1.3 ===
--- Zope3/lib/python/ZODB/interfaces.py:1.2	Fri Dec 20 13:55:08 2002
+++ Zope3/lib/python/ZODB/interfaces.py	Sat Dec 21 08:21:28 2002
@@ -12,7 +12,9 @@
 # 
 ##############################################################################
 from Interface import Interface
-from Transaction.interfaces import ITransaction
+from Interface.Attribute import Attribute
+
+from Transaction.interfaces import ITransaction as _ITransaction
 
 class IConnection(Interface):
     """Interface required of Connection by ZODB DB.
@@ -44,8 +46,11 @@
     def cacheGC():
         pass
 
-class IZTransaction(ITransaction):
-    """Extends base ITransaction with with metadata."""
+class ITransaction(_ITransaction):
+    """Extends base ITransaction with with metadata.
+
+    Client code should use this interface to set attributes.
+    """
 
     def note(text):
         """Add the text to the transaction description
@@ -63,3 +68,18 @@
 
     def setExtendedInfo(name, value):
         """Set extended information."""
+
+class ITransactionAttrs(_ITransaction):
+    # XXX The following attributes used by storages, so they are part
+    # of the interface.  But I'd rather not have user code explicitly
+    # use the attributes.
+
+    user = Attribute("The user as set by setUser()")
+    
+    description = Attribute("A description as set by note()")
+    
+    _extension = Attribute(
+        """Extended info as set by setExtendedInfo()
+
+        Should be None or a dictionary.""")
+    


=== Zope3/lib/python/ZODB/ZTransaction.py 1.4 => 1.5 ===
--- Zope3/lib/python/ZODB/ZTransaction.py:1.4	Fri Dec 20 13:30:45 2002
+++ Zope3/lib/python/ZODB/ZTransaction.py	Sat Dec 21 08:21:28 2002
@@ -14,11 +14,11 @@
 from Transaction import set_factory
 from Transaction.Transaction import Transaction as BaseTransaction
 
-from ZODB.interfaces import IZTransaction
+from ZODB.interfaces import ITransaction, ITransactionAttrs
 
 class Transaction(BaseTransaction):
 
-    __implements__ = IZTransaction
+    __implements__ = ITransaction, ITransactionAttrs
 
     user = ""
     description = ""


=== Zope3/lib/python/ZODB/BaseStorage.py 1.26 => 1.27 ===
--- Zope3/lib/python/ZODB/BaseStorage.py:1.26	Wed Dec 11 18:40:50 2002
+++ Zope3/lib/python/ZODB/BaseStorage.py	Sat Dec 21 08:21:28 2002
@@ -21,6 +21,7 @@
 import threading
 from ZODB import POSException
 from ZODB.TimeStamp import newTimeStamp, TimeStamp
+from ZODB.interfaces import ITransactionAttrs
 z64='\0'*8
 
 class BaseStorage:
@@ -119,6 +120,7 @@
         pass
 
     def tpc_begin(self, transaction, tid=None, status=' '):
+        assert ITransactionAttrs.isImplementedBy(transaction)
         if self._is_read_only:
             raise POSException.ReadOnlyError()
         self._lock_acquire()
@@ -298,6 +300,8 @@
 
 class TransactionRecord:
     """Abstract base class for iterator protocol."""
+
+    __implements__ = ITransactionAttrs
 
 class DataRecord:
     """Abstract base class for iterator protocol."""