[Zodb-checkins] SVN: ZODB/branches/jinty-doom/src/transaction/_
Clean up wierd import dance with ZODB. This is unnecessary
since the transaction module stopped being imported in
ZODB/__init__.py in rev 39622.
Brian Sutherland
jinty at web.de
Fri Sep 8 08:43:26 EDT 2006
Log message for revision 70053:
Clean up wierd import dance with ZODB. This is unnecessary since the transaction module stopped being imported in ZODB/__init__.py in rev 39622.
Changed:
U ZODB/branches/jinty-doom/src/transaction/_manager.py
U ZODB/branches/jinty-doom/src/transaction/_transaction.py
-=-
Modified: ZODB/branches/jinty-doom/src/transaction/_manager.py
===================================================================
--- ZODB/branches/jinty-doom/src/transaction/_manager.py 2006-09-08 12:27:59 UTC (rev 70052)
+++ ZODB/branches/jinty-doom/src/transaction/_manager.py 2006-09-08 12:43:26 UTC (rev 70053)
@@ -19,9 +19,11 @@
import thread
+from ZODB.utils import WeakSet, deprecated37
+
from transaction._transaction import Transaction
-# Used for deprecated arguments. ZODB.utils.DEPRECATED_ARGUMENT is
+# Used for deprecated arguments. ZODB.utils.DEPRECATED_ARGUMENT was
# too hard to use here, due to the convoluted import dance across
# __init__.py files.
_marker = object()
@@ -34,8 +36,6 @@
# alive (e.g., the cache, and everything reachable from it too).
# Therefore we use "weak sets" internally.
#
-# Obscure: because of the __init__.py maze, we can't import WeakSet
-# at top level here.
# Call the ISynchronizer newTransaction() method on every element of
# WeakSet synchs.
@@ -58,8 +58,6 @@
class TransactionManager(object):
def __init__(self):
- from ZODB.utils import WeakSet
-
self._txn = None
self._synchs = WeakSet()
@@ -95,7 +93,6 @@
if sub is _marker:
sub = None
else:
- from ZODB.utils import deprecated37
deprecated37("subtransactions are deprecated; use "
"transaction.savepoint() instead of "
"transaction.commit(1)")
@@ -105,7 +102,6 @@
if sub is _marker:
sub = None
else:
- from ZODB.utils import deprecated37
deprecated37("subtransactions are deprecated; use "
"sp.rollback() instead of "
"transaction.abort(1), where `sp` is the "
@@ -138,7 +134,6 @@
synchs = self._synchs.get(tid)
if synchs is None:
- from ZODB.utils import WeakSet
synchs = self._synchs[tid] = WeakSet()
txn = self._txns[tid] = Transaction(synchs, self)
@@ -151,7 +146,6 @@
if txn is None:
synchs = self._synchs.get(tid)
if synchs is None:
- from ZODB.utils import WeakSet
synchs = self._synchs[tid] = WeakSet()
txn = self._txns[tid] = Transaction(synchs, self)
return txn
@@ -165,7 +159,6 @@
tid = thread.get_ident()
ws = self._synchs.get(tid)
if ws is None:
- from ZODB.utils import WeakSet
ws = self._synchs[tid] = WeakSet()
ws.add(synch)
Modified: ZODB/branches/jinty-doom/src/transaction/_transaction.py
===================================================================
--- ZODB/branches/jinty-doom/src/transaction/_transaction.py 2006-09-08 12:27:59 UTC (rev 70052)
+++ ZODB/branches/jinty-doom/src/transaction/_transaction.py 2006-09-08 12:43:26 UTC (rev 70053)
@@ -169,16 +169,14 @@
from cStringIO import StringIO
from zope import interface
-from transaction import interfaces
+from ZODB.utils import WeakSet
+from ZODB.utils import deprecated37, deprecated38
+from ZODB.POSException import TransactionFailedError
+from ZODB.utils import oid_repr
-# Sigh. In the maze of __init__.py's, ZODB.__init__.py takes 'get'
-# out of transaction.__init__.py, in order to stuff the 'get_transaction'
-# alias in __builtin__. So here in _transaction.py, we can't import
-# exceptions from ZODB.POSException at top level (we're imported by
-# our __init__.py, which is imported by ZODB's __init__, so the ZODB
-# package isn't well-formed when we're first imported).
-# from ZODB.POSException import TransactionError, TransactionFailedError
+from transaction import interfaces
+
_marker = object()
# The point of this is to avoid hiding exceptions (which the builtin
@@ -229,7 +227,6 @@
# Weak set of synchronizer objects to call.
if synchronizers is None:
- from ZODB.utils import WeakSet
synchronizers = WeakSet()
self._synchronizers = synchronizers
@@ -275,7 +272,6 @@
# getting called when the current transaction has already suffered
# a commit/savepoint failure.
def _prior_operation_failed(self):
- from ZODB.POSException import TransactionFailedError
assert self._failure_traceback is not None
raise TransactionFailedError("An operation previously failed, "
"with traceback:\n\n%s" %
@@ -383,7 +379,6 @@
if subtransaction is _marker:
subtransaction = 0
elif deprecation_wng:
- from ZODB.utils import deprecated37
deprecated37("subtransactions are deprecated; instead of "
"transaction.commit(1), use "
"transaction.savepoint(optimistic=True) in "
@@ -448,7 +443,6 @@
self._before_commit.append((hook, tuple(args), kws))
def beforeCommitHook(self, hook, *args, **kws):
- from ZODB.utils import deprecated38
deprecated38("Use addBeforeCommitHook instead of beforeCommitHook.")
self.addBeforeCommitHook(hook, args, kws)
@@ -556,7 +550,6 @@
if subtransaction is _marker:
subtransaction = 0
elif deprecation_wng:
- from ZODB.utils import deprecated37
deprecated37("subtransactions are deprecated; use "
"sp.rollback() instead of "
"transaction.abort(1), where `sp` is the "
@@ -676,8 +669,6 @@
This function does not raise an exception.
"""
- from ZODB.utils import oid_repr
-
# We should always be able to get __class__.
klass = o.__class__.__name__
# oid would be great, but may this isn't a persistent object.
More information about the Zodb-checkins
mailing list