Commit b36489aa authored by Christian Theune's avatar Christian Theune

- style cleanups

parent 1e863cd1
......@@ -30,15 +30,16 @@ from struct import pack, unpack
fsync = getattr(os, "fsync", None)
from ZODB import BaseStorage, ConflictResolution, POSException
from ZODB.POSException \
import UndoError, POSKeyError, MultipleUndoErrors, VersionLockError
from ZODB.POSException import UndoError, POSKeyError, MultipleUndoErrors
from ZODB.POSException import VersionLockError
from persistent.TimeStamp import TimeStamp
from ZODB.lock_file import LockFile
from ZODB.utils import p64, u64, cp, z64
from ZODB.FileStorage.fspack import FileStoragePacker
from ZODB.FileStorage.format \
import FileStorageFormatter, DataHeader, TxnHeader, DATA_HDR, \
DATA_HDR_LEN, TRANS_HDR, TRANS_HDR_LEN, CorruptedDataError
from ZODB.FileStorage.format import FileStorageFormatter, DataHeader
from ZODB.FileStorage.format import TxnHeader, DATA_HDR, DATA_HDR_LEN
from ZODB.FileStorage.format import TRANS_HDR, TRANS_HDR_LEN
from ZODB.FileStorage.format import CorruptedDataError
from ZODB.loglevels import BLATHER
from ZODB.fsIndex import fsIndex
......
# this is a package
from ZODB.FileStorage.FileStorage \
import FileStorage, RecordIterator, FileIterator, Record, packed_version
from ZODB.FileStorage.FileStorage import FileStorage, RecordIterator
from ZODB.FileStorage.FileStorage import FileIterator, Record, packed_version
......@@ -30,9 +30,8 @@ from ZODB.serialize import referencesf
from ZODB.utils import p64, u64, z64
from ZODB.fsIndex import fsIndex
from ZODB.FileStorage.format \
import FileStorageFormatter, CorruptedDataError, DataHeader, \
TRANS_HDR_LEN
from ZODB.FileStorage.format import FileStorageFormatter, CorruptedDataError
from ZODB.FileStorage.format import DataHeader, TRANS_HDR_LEN
class DataCopier(FileStorageFormatter):
"""Mixin class for copying transactions into a storage.
......
......@@ -21,8 +21,8 @@ Caution: This file needs to be kept in sync with FileStorage.py.
import cPickle
import struct
from ZODB.FileStorage.format import TRANS_HDR, DATA_HDR, TRANS_HDR_LEN, \
DATA_HDR_LEN, DATA_VERSION_HDR_LEN
from ZODB.FileStorage.format import TRANS_HDR, DATA_HDR, TRANS_HDR_LEN
from ZODB.FileStorage.format import DATA_HDR_LEN, DATA_VERSION_HDR_LEN
from ZODB.utils import u64
from persistent.TimeStamp import TimeStamp
......
......@@ -230,8 +230,8 @@ class IConnection(Interface):
# Multi-database support.
connections = Attribute("""\
A mapping from database name to a Connection to that database.
connections = Attribute(
"""A mapping from database name to a Connection to that database.
In multi-database use, the Connections of all members of a database
collection share the same .connections object.
......@@ -345,8 +345,8 @@ class IDatabase(IStorageDB):
TODO: This interface is incomplete.
"""
databases = Attribute("""\
A mapping from database name to DB (database) object.
databases = Attribute(
"""A mapping from database name to DB (database) object.
In multi-database use, all DB members of a database collection share
the same .databases object.
......
......@@ -258,16 +258,16 @@ def doit(srcdb, dstdb, options):
t = TimeStamp(tid)
if t <= ts:
if ok:
print >> sys.stderr, \
'Time stamps are out of order %s, %s' % (ts, t)
print >> sys.stderr, (
'Time stamps are out of order %s, %s' % (ts, t))
ok = False
ts = t.laterThan(ts)
tid = `ts`
else:
ts = t
if not ok:
print >> sys.stderr, \
'Time stamps are back in order %s' % t
print >> sys.stderr, (
'Time stamps are back in order %s' % t)
ok = True
if verbose > 1:
print ts
......
......@@ -229,11 +229,11 @@ class ObjectWriter:
If the jar doesn't match that of the writer, an error is raised:
>>> bob._p_jar = DummyJar()
>>> writer.persistent_id(bob)
>>> writer.persistent_id(bob) # doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
InvalidObjectReference: Attempt to store an object from a """ \
"""foreign database connection
InvalidObjectReference: Attempt to store an object from a
foreign database connection
Constructor arguments used by __new__(), as returned by
__getnewargs__(), can affect memory allocation, but may also
......
......@@ -21,8 +21,8 @@ All storages should be able to pass these tests.
from ZODB import POSException
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase \
import zodb_unpickle, zodb_pickle, handle_serials
from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle
from ZODB.tests.StorageTestBase import handle_serials
import transaction
......
......@@ -7,8 +7,8 @@ from persistent.mapping import PersistentMapping
import transaction
import ZODB
from ZODB.tests.StorageTestBase \
import zodb_pickle, zodb_unpickle, handle_serials
from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
from ZODB.tests.StorageTestBase import handle_serials
from ZODB.tests.MinPO import MinPO
from ZODB.POSException import ConflictError
......
......@@ -14,8 +14,8 @@
"""Check loadSerial() on storages that support historical revisions."""
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import \
zodb_unpickle, zodb_pickle, snooze, handle_serials
from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle, snooze
from ZODB.tests.StorageTestBase import handle_serials
from ZODB.utils import p64, u64
import transaction
......
......@@ -24,7 +24,7 @@ from zope.testing.doctest import DocTestSuite
from ZODB.tests.util import DB
def test_integration():
"""Test the integration of broken object support with the databse:
r"""Test the integration of broken object support with the databse:
>>> db = DB()
......@@ -64,9 +64,9 @@ def test_integration():
>>> conn3 = db.open()
>>> a3 = conn3.root()['a']
>>> a3
<persistent broken ZODB.not.there.Atall instance """ \
r"""'\x00\x00\x00\x00\x00\x00\x00\x01'>
>>> a3 # doctest: +NORMALIZE_WHITESPACE
<persistent broken ZODB.not.there.Atall instance
'\x00\x00\x00\x00\x00\x00\x00\x01'>
>>> a3.__Broken_state__
{'x': 1}
......
......@@ -444,10 +444,8 @@ class InvalidationTests(unittest.TestCase):
"""
def test_invalidateCache():
"""\
The invalidateCache method invalidates a connection's cache. It also
prevents reads until the end of a transaction.
"""The invalidateCache method invalidates a connection's cache. It also
prevents reads until the end of a transaction::
>>> from ZODB.tests.util import DB
>>> import transaction
......@@ -464,26 +462,26 @@ prevents reads until the end of a transaction.
>>> connection.root()['b']._p_deactivate()
>>> connection.root()['c'].x = 2
So we have a connection and an active transaction with some
modifications. Lets call invalidateCache:
So we have a connection and an active transaction with some modifications.
Lets call invalidateCache:
>>> connection.invalidateCache()
Now, if we try to load an object, we'll get a read conflict:
Now, if we try to load an object, we'll get a read conflict:
>>> connection.root()['b'].x
Traceback (most recent call last):
...
ReadConflictError: database read conflict error
If we try to commit the transaction, we'll get a conflict error:
If we try to commit the transaction, we'll get a conflict error:
>>> tm.commit()
Traceback (most recent call last):
...
ConflictError: database conflict error
and the cache will have been cleared:
and the cache will have been cleared:
>>> print connection.root()['a']._p_changed
None
......@@ -492,13 +490,13 @@ and the cache will have been cleared:
>>> print connection.root()['c']._p_changed
None
But we'll be able to access data again:
But we'll be able to access data again:
>>> connection.root()['b'].x
1
Aborting a transaction after a read conflict also lets us read data
and go on about our business:
Aborting a transaction after a read conflict also lets us read data and go
on about our business:
>>> connection.invalidateCache()
......
......@@ -143,9 +143,8 @@ class DBTests(unittest.TestCase):
def test_invalidateCache():
"""\
The invalidateCache method invalidates a connection caches for all of the connections attached to a database.
"""The invalidateCache method invalidates a connection caches for all of
the connections attached to a database::
>>> from ZODB.tests.util import DB
>>> import transaction
......@@ -183,7 +182,6 @@ The invalidateCache method invalidates a connection caches for all of the connec
"""
def test_suite():
s = unittest.makeSuite(DBTests)
s.addTest(doctest.DocTestSuite())
......
......@@ -18,12 +18,12 @@ import ZODB.tests.util
from ZODB import POSException
from ZODB import DB
from ZODB.tests import StorageTestBase, BasicStorage, \
TransactionalUndoStorage, VersionStorage, \
TransactionalUndoVersionStorage, PackableStorage, \
Synchronization, ConflictResolution, HistoryStorage, \
IteratorStorage, Corruption, RevisionStorage, PersistentStorage, \
MTStorage, ReadOnlyStorage, RecoveryStorage
from ZODB.tests import StorageTestBase, BasicStorage, TransactionalUndoStorage
from ZODB.tests import VersionStorage, TransactionalUndoVersionStorage
from ZODB.tests import PackableStorage, Synchronization, ConflictResolution
from ZODB.tests import HistoryStorage, IteratorStorage, Corruption
from ZODB.tests import RevisionStorage, PersistentStorage, MTStorage
from ZODB.tests import ReadOnlyStorage, RecoveryStorage
from ZODB.tests.StorageTestBase import MinPO, zodb_pickle
class BaseFileStorageTests(StorageTestBase.StorageTestBase):
......
......@@ -15,8 +15,8 @@ import ZODB.MappingStorage
import unittest
from ZODB.tests import StorageTestBase
from ZODB.tests \
import BasicStorage, MTStorage, Synchronization, PackableStorage
from ZODB.tests import BasicStorage, MTStorage, Synchronization
from ZODB.tests import PackableStorage
class MappingStorageTests(StorageTestBase.StorageTestBase,
BasicStorage.BasicStorage,
......
......@@ -28,9 +28,8 @@ from ZODB import POSException
from ZODB.utils import z64
from ZODB.tests import StorageTestBase
from ZODB.tests \
import BasicStorage, MTStorage, Synchronization, PackableStorage, \
RevisionStorage
from ZODB.tests import BasicStorage, MTStorage, Synchronization
from ZODB.tests import PackableStorage, RevisionStorage
class Transaction(object):
"""Hold data for current transaction for MinimalMemoryStorage."""
......
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