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