Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zodb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joshua
zodb
Commits
c3655ce6
Commit
c3655ce6
authored
Jun 06, 2007
by
Christian Theune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- style cleanups
parent
637c2bd0
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
135 additions
and
140 deletions
+135
-140
src/ZODB/FileStorage/FileStorage.py
src/ZODB/FileStorage/FileStorage.py
+6
-5
src/ZODB/FileStorage/__init__.py
src/ZODB/FileStorage/__init__.py
+2
-2
src/ZODB/FileStorage/fspack.py
src/ZODB/FileStorage/fspack.py
+2
-3
src/ZODB/fstools.py
src/ZODB/fstools.py
+2
-2
src/ZODB/interfaces.py
src/ZODB/interfaces.py
+4
-4
src/ZODB/scripts/migrate.py
src/ZODB/scripts/migrate.py
+4
-4
src/ZODB/serialize.py
src/ZODB/serialize.py
+3
-3
src/ZODB/tests/BasicStorage.py
src/ZODB/tests/BasicStorage.py
+2
-2
src/ZODB/tests/MTStorage.py
src/ZODB/tests/MTStorage.py
+2
-2
src/ZODB/tests/RevisionStorage.py
src/ZODB/tests/RevisionStorage.py
+2
-2
src/ZODB/tests/testBroken.py
src/ZODB/tests/testBroken.py
+4
-4
src/ZODB/tests/testConnection.py
src/ZODB/tests/testConnection.py
+56
-58
src/ZODB/tests/testDB.py
src/ZODB/tests/testDB.py
+36
-38
src/ZODB/tests/testFileStorage.py
src/ZODB/tests/testFileStorage.py
+6
-6
src/ZODB/tests/testMappingStorage.py
src/ZODB/tests/testMappingStorage.py
+2
-2
src/ZODB/tests/test_storage.py
src/ZODB/tests/test_storage.py
+2
-3
No files found.
src/ZODB/FileStorage/FileStorage.py
View file @
c3655ce6
...
...
@@ -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
...
...
src/ZODB/FileStorage/__init__.py
View file @
c3655ce6
# 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
src/ZODB/FileStorage/fspack.py
View file @
c3655ce6
...
...
@@ -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.
...
...
src/ZODB/fstools.py
View file @
c3655ce6
...
...
@@ -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
...
...
src/ZODB/interfaces.py
View file @
c3655ce6
...
...
@@ -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.
...
...
src/ZODB/scripts/migrate.py
View file @
c3655ce6
...
...
@@ -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
...
...
src/ZODB/serialize.py
View file @
c3655ce6
...
...
@@ -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
...
...
src/ZODB/tests/BasicStorage.py
View file @
c3655ce6
...
...
@@ -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
...
...
src/ZODB/tests/MTStorage.py
View file @
c3655ce6
...
...
@@ -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
...
...
src/ZODB/tests/RevisionStorage.py
View file @
c3655ce6
...
...
@@ -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
...
...
src/ZODB/tests/testBroken.py
View file @
c3655ce6
...
...
@@ -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}
...
...
src/ZODB/tests/testConnection.py
View file @
c3655ce6
...
...
@@ -444,77 +444,75 @@ 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
>>> db = DB()
>>> tm = transaction.TransactionManager()
>>> connection = db.open(transaction_manager=tm)
>>> connection.root()['a'] = StubObject()
>>> connection.root()['a'].x = 1
>>> connection.root()['b'] = StubObject()
>>> connection.root()['b'].x = 1
>>> connection.root()['c'] = StubObject()
>>> connection.root()['c'].x = 1
>>> tm.commit()
>>> 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:
>>> connection.invalidateCache()
Now, if we try to load an object, we'll get a read conflict:
>>> from ZODB.tests.util import DB
>>> import transaction
>>> db = DB()
>>> tm = transaction.TransactionManager()
>>> connection = db.open(transaction_manager=tm)
>>> connection.root()['a'] = StubObject()
>>> connection.root()['a'].x = 1
>>> connection.root()['b'] = StubObject()
>>> connection.root()['b'].x = 1
>>> connection.root()['c'] = StubObject()
>>> connection.root()['c'].x = 1
>>> tm.commit()
>>> 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:
>>> connection.invalidateCache()
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
>>> 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
>>> 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
>>> print connection.root()['b']._p_changed
None
>>> print connection.root()['c']._p_changed
None
>>> print connection.root()['a']._p_changed
None
>>> print connection.root()['b']._p_changed
None
>>> 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
>>> 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()
>>> connection.invalidateCache()
>>> connection.root()['c'].x
Traceback (most recent call last):
...
ReadConflictError: database read conflict error
>>> connection.root()['c'].x
Traceback (most recent call last):
...
ReadConflictError: database read conflict error
>>> tm.abort()
>>> connection.root()['c'].x
1
>>> tm.abort()
>>> connection.root()['c'].x
1
>>> connection.root()['c'].x = 2
>>> tm.commit()
>>> connection.root()['c'].x = 2
>>> tm.commit()
>>> db.close()
>>> db.close()
"""
# ---- stubs
...
...
src/ZODB/tests/testDB.py
View file @
c3655ce6
...
...
@@ -143,47 +143,45 @@ class DBTests(unittest.TestCase):
def
test_invalidateCache
():
"""
\
The invalidateCache method invalidates a connection caches for all of the connections attached to a database.
>>> from ZODB.tests.util import DB
>>> import transaction
>>> db = DB()
>>> tm1 = transaction.TransactionManager()
>>> c1 = db.open(transaction_manager=tm1)
>>> c1.root()['a'] = MinPO(1)
>>> tm1.commit()
>>> tm2 = transaction.TransactionManager()
>>> c2 = db.open(transaction_manager=tm2)
>>> c1.root()['a']._p_deactivate()
>>> tm3 = transaction.TransactionManager()
>>> c3 = db.open(transaction_manager=tm3)
>>> c3.root()['a'].value
1
>>> c3.close()
>>> db.invalidateCache()
>>> c1.root()['a'].value
Traceback (most recent call last):
...
ReadConflictError: database read conflict error
>>> c2.root()['a'].value
Traceback (most recent call last):
...
ReadConflictError: database read conflict error
>>> c3 is db.open(transaction_manager=tm3)
True
>>> print c3.root()['a']._p_changed
None
>>> db.close()
"""The invalidateCache method invalidates a connection caches for all of
the connections attached to a database::
>>> from ZODB.tests.util import DB
>>> import transaction
>>> db = DB()
>>> tm1 = transaction.TransactionManager()
>>> c1 = db.open(transaction_manager=tm1)
>>> c1.root()['a'] = MinPO(1)
>>> tm1.commit()
>>> tm2 = transaction.TransactionManager()
>>> c2 = db.open(transaction_manager=tm2)
>>> c1.root()['a']._p_deactivate()
>>> tm3 = transaction.TransactionManager()
>>> c3 = db.open(transaction_manager=tm3)
>>> c3.root()['a'].value
1
>>> c3.close()
>>> db.invalidateCache()
>>> c1.root()['a'].value
Traceback (most recent call last):
...
ReadConflictError: database read conflict error
>>> c2.root()['a'].value
Traceback (most recent call last):
...
ReadConflictError: database read conflict error
>>> c3 is db.open(transaction_manager=tm3)
True
>>> print c3.root()['a']._p_changed
None
>>> db.close()
"""
def
test_suite
():
s
=
unittest
.
makeSuite
(
DBTests
)
s
.
addTest
(
doctest
.
DocTestSuite
())
...
...
src/ZODB/tests/testFileStorage.py
View file @
c3655ce6
...
...
@@ -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
):
...
...
src/ZODB/tests/testMappingStorage.py
View file @
c3655ce6
...
...
@@ -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
,
...
...
src/ZODB/tests/test_storage.py
View file @
c3655ce6
...
...
@@ -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."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment