[Zodb-checkins] SVN: ZODB/branches/3.4/src/ Refined interfaces to
distinguish between data-manager savepoints and
Jim Fulton
jim at zope.com
Sun Apr 24 11:26:37 EDT 2005
Log message for revision 30146:
Refined interfaces to distinguish between data-manager savepoints and
transaction savepoints.
Updated some interface declarations.
Changed:
U ZODB/branches/3.4/src/ZODB/Connection.py
U ZODB/branches/3.4/src/transaction/interfaces.py
U ZODB/branches/3.4/src/transaction/tests/savepointsample.py
-=-
Modified: ZODB/branches/3.4/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/3.4/src/ZODB/Connection.py 2005-04-24 14:48:15 UTC (rev 30145)
+++ ZODB/branches/3.4/src/ZODB/Connection.py 2005-04-24 15:26:37 UTC (rev 30146)
@@ -27,7 +27,7 @@
# interfaces
from persistent.interfaces import IPersistentDataManager
from ZODB.interfaces import IConnection
-from transaction.interfaces import IDataManager
+from transaction.interfaces import ISavepointDataManager, IDataManagerSavepoint
from zope.interface import implements
import transaction
@@ -59,7 +59,7 @@
class Connection(ExportImport, object):
"""Connection to ZODB for loading and storing objects."""
- implements(IConnection, IDataManager, IPersistentDataManager)
+ implements(IConnection, ISavepointDataManager, IPersistentDataManager)
_storage = _normal_storage = _savepoint_storage = None
@@ -319,7 +319,7 @@
##########################################################################
##########################################################################
- # Data manager (IDataManager) methods
+ # Data manager (ISavepointDataManager) methods
def abort(self, transaction):
"""Abort a transaction and forget all changes."""
@@ -638,7 +638,7 @@
"""Return a consistent sort key for this connection."""
return "%s:%s" % (self._storage.sortKey(), id(self))
- # Data manager (IDataManager) methods
+ # Data manager (ISavepointDataManager) methods
##########################################################################
##########################################################################
@@ -1061,6 +1061,8 @@
class Savepoint:
+ implements(IDataManagerSavepoint)
+
def __init__(self, datamanager, state):
self.datamanager = datamanager
self.state = state
Modified: ZODB/branches/3.4/src/transaction/interfaces.py
===================================================================
--- ZODB/branches/3.4/src/transaction/interfaces.py 2005-04-24 14:48:15 UTC (rev 30145)
+++ ZODB/branches/3.4/src/transaction/interfaces.py 2005-04-24 15:26:37 UTC (rev 30146)
@@ -308,9 +308,27 @@
class ISavepointDataManager(IDataManager):
def savepoint():
- """Return a savepoint (ISavepoint)
+ """Return a data-manager savepoint (IDataManagerSavepoint)
"""
+class IDataManagerSavepoint(zope.interface.Interface):
+ """Savepoint for data-manager changes for use in transaction savepoints
+
+ Datamanager savepoints are used by, and only by, transaction savepoints.
+
+ Note that data manager savepoints don't have any notion of or
+ responsibility for validity. It isn't the responsibility of
+ data-manager savepoints to prevent multiple rollbacks or rollbacks
+ after transaction termination. Preventing invalid savepoint
+ rollback is the responsibility of transaction rollbacks.
+ Application code should never use data-manager savepoints.
+
+ """
+
+ def rollback():
+ """Rollback any work done since the savepoint
+ """
+
class ISavepoint(zope.interface.Interface):
"""A transaction savepoint
"""
Modified: ZODB/branches/3.4/src/transaction/tests/savepointsample.py
===================================================================
--- ZODB/branches/3.4/src/transaction/tests/savepointsample.py 2005-04-24 14:48:15 UTC (rev 30145)
+++ ZODB/branches/3.4/src/transaction/tests/savepointsample.py 2005-04-24 15:26:37 UTC (rev 30146)
@@ -30,7 +30,7 @@
This data manager stores named simple values, like strings and numbers.
"""
- interface.implements(transaction.interfaces.ISavepointDataManager)
+ interface.implements(transaction.interfaces.IDataManager)
def __init__(self, transaction_manager = None):
if transaction_manager is None:
@@ -156,6 +156,8 @@
This extends the basic data manager with savepoint support.
"""
+ interface.implements(transaction.interfaces.ISavepointDataManager)
+
def savepoint(self):
# When we create the savepoint, we save the existing database state
return SampleSavepoint(self, self.uncommitted.copy())
@@ -166,6 +168,8 @@
class SampleSavepoint:
+ interface.implements(transaction.interfaces.IDataManagerSavepoint)
+
def __init__(self, data_manager, data):
self.data_manager = data_manager
self.data = data
More information about the Zodb-checkins
mailing list