Commit ce44b3ab authored by Tres Seaver's avatar Tres Seaver

Dropp use of Python3-impatible 'zope.interface.implements' class advisor

Instead, use (only) the 'zope.interface.implementer' class decorator.
parent e2032274
......@@ -4,6 +4,9 @@ Changes
1.2.1 (unreleased)
------------------
- Dropped use of Python3-impatible ``zope.interface.implements`` class
advisor in favor of ``zope.interface.implementer`` class decorator.
- Added support for continuous integration using ``tox`` and ``jenkins``.
- Added ``setup.py docs`` alias (installs ``Sphinx`` and dependencies).
......
......@@ -103,7 +103,7 @@ import sys
import weakref
import traceback
from zope import interface
from zope.interface import implementer
from transaction.compat import reraise
from transaction.compat import get_thread_ident
......@@ -134,10 +134,10 @@ class Status:
# to commit or join this transaction will raise TransactionFailedError.
COMMITFAILED = "Commit failed"
@implementer(interfaces.ITransaction,
interfaces.ITransactionDeprecated)
class Transaction(object):
interface.implements(interfaces.ITransaction,
interfaces.ITransactionDeprecated)
# Assign an index to each savepoint so we can invalidate later savepoints
......@@ -672,13 +672,13 @@ class DataManagerAdapter(object):
def sortKey(self):
return self._datamanager.sortKey()
@implementer(interfaces.ISavepoint)
class Savepoint:
"""Transaction savepoint.
Transaction savepoints coordinate savepoints for data managers
participating in a transaction.
"""
interface.implements(interfaces.ISavepoint)
valid = property(lambda self: self.transaction is not None)
......
......@@ -26,9 +26,9 @@ use savepoints and doom() safely.
To see how it works we first need to create a stub data manager:
>>> from transaction.interfaces import IDataManager
>>> from zope.interface import implements
>>> class DataManager:
... implements(IDataManager)
>>> from zope.interface import implementer
>>> @implementer(IDataManager)
... class DataManager:
... def __init__(self):
... self.attr_counter = {}
... def __getattr__(self, name):
......
......@@ -19,18 +19,16 @@ savepoints.
See savepoint.txt in the transaction package.
"""
from zope import interface
from zope.interface import implementer
import transaction.interfaces
@interface.implementer(transaction.interfaces.IDataManager)
@implementer(transaction.interfaces.IDataManager)
class SampleDataManager(object):
"""Sample implementation of data manager that doesn't support savepoints
This data manager stores named simple values, like strings and numbers.
"""
interface.implements(transaction.interfaces.IDataManager)
def __init__(self, transaction_manager=None):
if transaction_manager is None:
# Use the thread-local transaction manager if none is provided:
......@@ -162,15 +160,13 @@ class SampleDataManager(object):
#
#######################################################################
@interface.implementer(transaction.interfaces.ISavepointDataManager)
@implementer(transaction.interfaces.ISavepointDataManager)
class SampleSavepointDataManager(SampleDataManager):
"""Sample implementation of a savepoint-supporting data manager
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())
......@@ -184,11 +180,9 @@ class SampleSavepointDataManager(SampleDataManager):
# savepoint was done again. IOW, copy() is necessary.
self.uncommitted = savepoint.data.copy()
@interface.implementer(transaction.interfaces.IDataManagerSavepoint)
@implementer(transaction.interfaces.IDataManagerSavepoint)
class SampleSavepoint:
interface.implements(transaction.interfaces.IDataManagerSavepoint)
def __init__(self, data_manager, data):
self.data_manager = data_manager
self.data = data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment