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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
ZODB
Commits
f371a71c
Commit
f371a71c
authored
Jul 26, 2016
by
Jim Fulton
Committed by
GitHub
Jul 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #93 from zopefoundation/drop-old-commit-protocol
Drop old commit protocol
parents
683f7faf
420984b7
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
92 additions
and
324 deletions
+92
-324
src/ZODB/ConflictResolution.py
src/ZODB/ConflictResolution.py
+0
-2
src/ZODB/Connection.py
src/ZODB/Connection.py
+22
-57
src/ZODB/blob.py
src/ZODB/blob.py
+1
-2
src/ZODB/interfaces.py
src/ZODB/interfaces.py
+3
-48
src/ZODB/multicommitadapter.py
src/ZODB/multicommitadapter.py
+0
-65
src/ZODB/mvccadapter.py
src/ZODB/mvccadapter.py
+3
-9
src/ZODB/tests/StorageTestBase.py
src/ZODB/tests/StorageTestBase.py
+6
-8
src/ZODB/tests/TransactionalUndoStorage.py
src/ZODB/tests/TransactionalUndoStorage.py
+56
-130
src/ZODB/tests/testConnection.py
src/ZODB/tests/testConnection.py
+1
-3
No files found.
src/ZODB/ConflictResolution.py
View file @
f371a71c
...
@@ -28,8 +28,6 @@ from pickle import PicklingError
...
@@ -28,8 +28,6 @@ from pickle import PicklingError
logger
=
logging
.
getLogger
(
'ZODB.ConflictResolution'
)
logger
=
logging
.
getLogger
(
'ZODB.ConflictResolution'
)
ResolvedSerial
=
b'rs'
# deprecated: see IMultiCommitStorage.tpc_vote
class
BadClassName
(
Exception
):
class
BadClassName
(
Exception
):
pass
pass
...
...
src/ZODB/Connection.py
View file @
f371a71c
...
@@ -37,7 +37,6 @@ import transaction
...
@@ -37,7 +37,6 @@ import transaction
import
ZODB
import
ZODB
from
ZODB.blob
import
SAVEPOINT_SUFFIX
from
ZODB.blob
import
SAVEPOINT_SUFFIX
from
ZODB.ConflictResolution
import
ResolvedSerial
from
ZODB.ExportImport
import
ExportImport
from
ZODB.ExportImport
import
ExportImport
from
ZODB
import
POSException
from
ZODB
import
POSException
from
ZODB.POSException
import
InvalidObjectReference
,
ConnectionStateError
from
ZODB.POSException
import
InvalidObjectReference
,
ConnectionStateError
...
@@ -589,27 +588,13 @@ class Connection(ExportImport, object):
...
@@ -589,27 +588,13 @@ class Connection(ExportImport, object):
self
.
_cache
.
update_object_size_estimation
(
oid
,
len
(
p
))
self
.
_cache
.
update_object_size_estimation
(
oid
,
len
(
p
))
obj
.
_p_estimated_size
=
len
(
p
)
obj
.
_p_estimated_size
=
len
(
p
)
self
.
_handle_serial
(
oid
,
s
)
# if we write an object, we don't want to check if it was read
# while current. This is a convenient choke point to do this.
def
_handle_serial
(
self
,
oid
,
serial
=
ResolvedSerial
,
change
=
True
):
self
.
_readCurrent
.
pop
(
oid
,
None
)
if
s
:
# if we write an object, we don't want to check if it was read
# savepoint
# while current. This is a convenient choke point to do this.
self
.
_readCurrent
.
pop
(
oid
,
None
)
if
not
serial
:
return
assert
isinstance
(
serial
,
bytes
),
serial
obj
=
self
.
_cache
.
get
(
oid
,
None
)
if
obj
is
None
:
return
if
serial
==
ResolvedSerial
:
del
obj
.
_p_changed
# transition from changed to ghost
else
:
self
.
_warn_about_returned_serial
()
if
change
:
obj
.
_p_changed
=
0
# transition from changed to up-to-date
obj
.
_p_changed
=
0
# transition from changed to up-to-date
obj
.
_p_serial
=
serial
obj
.
_p_serial
=
s
def
tpc_abort
(
self
,
transaction
):
def
tpc_abort
(
self
,
transaction
):
if
self
.
_import
:
if
self
.
_import
:
...
@@ -674,46 +659,27 @@ class Connection(ExportImport, object):
...
@@ -674,46 +659,27 @@ class Connection(ExportImport, object):
if
v
.
oid
:
if
v
.
oid
:
self
.
_cache
.
invalidate
(
v
.
oid
)
self
.
_cache
.
invalidate
(
v
.
oid
)
raise
raise
if
s
:
if
s
:
if
type
(
next
(
iter
(
s
)))
is
bytes
:
# Resolved conflicts.
for
oid
in
s
:
for
oid
in
s
:
self
.
_handle_serial
(
oid
)
obj
=
self
.
_cache
.
get
(
oid
)
return
if
obj
is
not
None
:
self
.
_warn_about_returned_serial
()
del
obj
.
_p_changed
# transition from changed to ghost
for
oid
,
serial
in
s
:
self
.
_handle_serial
(
oid
,
serial
)
def
tpc_finish
(
self
,
transaction
):
def
tpc_finish
(
self
,
transaction
):
"""Indicate confirmation that the transaction is done.
"""Indicate confirmation that the transaction is done.
"""
"""
serial
=
self
.
_storage
.
tpc_finish
(
transaction
)
serial
=
self
.
_storage
.
tpc_finish
(
transaction
)
if
serial
is
not
None
:
assert
type
(
serial
)
is
bytes
,
repr
(
serial
)
assert
type
(
serial
)
is
bytes
,
repr
(
serial
)
for
oid_iterator
in
self
.
_modified
,
self
.
_creating
:
for
oid_iterator
in
self
.
_modified
,
self
.
_creating
:
for
oid
in
oid_iterator
:
for
oid
in
oid_iterator
:
obj
=
self
.
_cache
.
get
(
oid
)
obj
=
self
.
_cache
.
get
(
oid
)
# Ignore missing objects and don't update ghosts.
# Ignore missing objects and don't update ghosts.
if
obj
is
not
None
and
obj
.
_p_changed
is
not
None
:
if
obj
is
not
None
and
obj
.
_p_changed
is
not
None
:
obj
.
_p_changed
=
0
obj
.
_p_changed
=
0
obj
.
_p_serial
=
serial
obj
.
_p_serial
=
serial
else
:
self
.
_warn_about_returned_serial
()
self
.
_tpc_cleanup
()
self
.
_tpc_cleanup
()
def
_warn_about_returned_serial
(
self
):
# Do not warn about own implementations of ZODB.
# We're aware and the user can't do anything about it.
if
self
.
_normal_storage
.
__module__
.
startswith
(
"_ZODB."
):
self
.
_warn_about_returned_serial
=
lambda
:
None
else
:
warnings
.
warn
(
"In ZODB 5+, the new API for the returned value of"
" store/tpc_vote/tpc_finish will be mandatory."
" See IStorage for more information."
,
DeprecationWarning
,
2
)
Connection
.
_warn_about_returned_serial
=
lambda
self
:
None
def
sortKey
(
self
):
def
sortKey
(
self
):
"""Return a consistent sort key for this connection."""
"""Return a consistent sort key for this connection."""
return
"%s:%s"
%
(
self
.
_storage
.
sortKey
(),
id
(
self
))
return
"%s:%s"
%
(
self
.
_storage
.
sortKey
(),
id
(
self
))
...
@@ -1033,7 +999,7 @@ class Connection(ExportImport, object):
...
@@ -1033,7 +999,7 @@ class Connection(ExportImport, object):
obj
.
_p_estimated_size
=
len
(
data
)
obj
.
_p_estimated_size
=
len
(
data
)
if
isinstance
(
self
.
_reader
.
getGhost
(
data
),
Blob
):
if
isinstance
(
self
.
_reader
.
getGhost
(
data
),
Blob
):
blobfilename
=
src
.
loadBlob
(
oid
,
serial
)
blobfilename
=
src
.
loadBlob
(
oid
,
serial
)
s
=
s
elf
.
_storage
.
storeBlob
(
self
.
_storage
.
storeBlob
(
oid
,
serial
,
data
,
blobfilename
,
oid
,
serial
,
data
,
blobfilename
,
''
,
transaction
)
''
,
transaction
)
# we invalidate the object here in order to ensure
# we invalidate the object here in order to ensure
...
@@ -1042,10 +1008,9 @@ class Connection(ExportImport, object):
...
@@ -1042,10 +1008,9 @@ class Connection(ExportImport, object):
# to be reattached "cleanly"
# to be reattached "cleanly"
self
.
_cache
.
invalidate
(
oid
)
self
.
_cache
.
invalidate
(
oid
)
else
:
else
:
s
=
self
.
_storage
.
store
(
oid
,
serial
,
data
,
self
.
_storage
.
store
(
oid
,
serial
,
data
,
''
,
transaction
)
''
,
transaction
)
self
.
_
handle_serial
(
oid
,
s
,
change
=
False
)
self
.
_
readCurrent
.
pop
(
oid
,
None
)
# same as in _store_objects(
)
finally
:
finally
:
src
.
close
()
src
.
close
()
...
...
src/ZODB/blob.py
View file @
f371a71c
...
@@ -709,9 +709,8 @@ class BlobStorageMixin(object):
...
@@ -709,9 +709,8 @@ class BlobStorageMixin(object):
transaction
):
transaction
):
"""Stores data that has a BLOB attached."""
"""Stores data that has a BLOB attached."""
assert
not
version
,
"Versions aren't supported."
assert
not
version
,
"Versions aren't supported."
se
rial
=
se
lf
.
store
(
oid
,
oldserial
,
data
,
''
,
transaction
)
self
.
store
(
oid
,
oldserial
,
data
,
''
,
transaction
)
self
.
_blob_storeblob
(
oid
,
self
.
_tid
,
blobfilename
)
self
.
_blob_storeblob
(
oid
,
self
.
_tid
,
blobfilename
)
return
serial
def
temporaryDirectory
(
self
):
def
temporaryDirectory
(
self
):
return
self
.
fshelper
.
temp_dir
return
self
.
fshelper
.
temp_dir
...
...
src/ZODB/interfaces.py
View file @
f371a71c
...
@@ -653,23 +653,6 @@ class IStorage(Interface):
...
@@ -653,23 +653,6 @@ class IStorage(Interface):
A transaction object. This should match the current
A transaction object. This should match the current
transaction for the storage, set by tpc_begin.
transaction for the storage, set by tpc_begin.
The new serial for the object is returned, but not necessarily
immediately. It may be returned directly, or on a subsequent
store or tpc_vote call.
The return value may be:
- None, or
- A new serial (string) for the object
If None is returned, then a new serial (or other special
values) must ve returned in tpc_vote results.
A serial, returned as a string, may be the special value
ZODB.ConflictResolution.ResolvedSerial to indicate that a
conflict occured and that the object should be invalidated.
Several different exceptions may be raised when an error occurs.
Several different exceptions may be raised when an error occurs.
ConflictError
ConflictError
...
@@ -739,18 +722,8 @@ class IStorage(Interface):
...
@@ -739,18 +722,8 @@ class IStorage(Interface):
without an error, then there must not be an error if
without an error, then there must not be an error if
tpc_finish or tpc_abort is called subsequently.
tpc_finish or tpc_abort is called subsequently.
The return value can be None or a sequence of object-id
The return value can be None or a sequence of a sequence of object ids,
and serial pairs giving new serials for objects whose ids were
as described in IMultiCommitStorage.tpc_vote.
passed to previous store calls in the same transaction. The serial
can be the special value ZODB.ConflictResolution.ResolvedSerial to
indicate that a conflict occurred and that the object should be
invalidated.
The return value can also be a sequence of object ids, as
described in IMultiCommitStorage.tpc_vote.
After the tpc_vote call, all solved conflicts must have been notified,
either from tpc_vote or store for objects passed to store.
"""
"""
...
@@ -790,7 +763,7 @@ class IMultiCommitStorage(IStorage):
...
@@ -790,7 +763,7 @@ class IMultiCommitStorage(IStorage):
def
tpc_vote
(
transaction
):
def
tpc_vote
(
transaction
):
"""Provide a storage with an opportunity to veto a transaction
"""Provide a storage with an opportunity to veto a transaction
See IStorage.
stor
e. For objects implementing this interface,
See IStorage.
tpc_vot
e. For objects implementing this interface,
the return value can be either None or a sequence of oids for which
the return value can be either None or a sequence of oids for which
a conflict was resolved.
a conflict was resolved.
"""
"""
...
@@ -1236,24 +1209,6 @@ class IBlobStorage(Interface):
...
@@ -1236,24 +1209,6 @@ class IBlobStorage(Interface):
(or copy and remove it) immediately, or at transaction-commit
(or copy and remove it) immediately, or at transaction-commit
time. The file must not be open.
time. The file must not be open.
The new serial for the object is returned, but not necessarily
immediately. It may be returned directly, or on a subsequent
store or tpc_vote call.
The return value may be:
- None
- A new serial (string) for the object, or
- An iterable of object-id and serial pairs giving new serials
for objects.
A serial, returned as a string or in a sequence of oid/serial
pairs, may be the special value
ZODB.ConflictResolution.ResolvedSerial to indicate that a
conflict occured and that the object should be invalidated.
Several different exceptions may be raised when an error occurs.
Several different exceptions may be raised when an error occurs.
ConflictError
ConflictError
...
...
src/ZODB/multicommitadapter.py
deleted
100644 → 0
View file @
683f7faf
"""Adapt non-IMultiCommitStorage storages to IMultiCommitStorage
"""
import
zope.interface
from
.ConflictResolution
import
ResolvedSerial
class
MultiCommitAdapter
:
def
__init__
(
self
,
storage
):
self
.
_storage
=
storage
ifaces
=
zope
.
interface
.
providedBy
(
storage
)
zope
.
interface
.
alsoProvides
(
self
,
ifaces
)
self
.
_resolved
=
set
()
# {OID}, here to make linters happy
def
__getattr__
(
self
,
name
):
v
=
getattr
(
self
.
_storage
,
name
)
self
.
__dict__
[
name
]
=
v
return
v
def
tpc_begin
(
self
,
*
args
):
self
.
_storage
.
tpc_begin
(
*
args
)
self
.
_resolved
=
set
()
def
store
(
self
,
oid
,
*
args
):
if
self
.
_storage
.
store
(
oid
,
*
args
)
==
ResolvedSerial
:
self
.
_resolved
.
add
(
oid
)
def
storeBlob
(
self
,
oid
,
*
args
):
s
=
self
.
_storage
.
storeBlob
(
oid
,
*
args
)
if
s
:
if
isinstance
(
s
,
bytes
):
s
=
((
oid
,
s
),
)
for
oid
,
serial
in
s
:
if
s
==
ResolvedSerial
:
self
.
_resolved
.
add
(
oid
)
def
undo
(
self
,
transaction_id
,
transaction
):
r
=
self
.
_storage
.
undo
(
transaction_id
,
transaction
)
if
r
:
self
.
_resolved
.
update
(
r
[
1
])
def
tpc_vote
(
self
,
*
args
):
s
=
self
.
_storage
.
tpc_vote
(
*
args
)
for
(
oid
,
serial
)
in
(
s
or
()):
if
serial
==
ResolvedSerial
:
self
.
_resolved
.
add
(
oid
)
return
self
.
_resolved
def
tpc_finish
(
self
,
transaction
,
f
=
lambda
tid
:
None
):
t
=
[]
def
func
(
tid
):
t
.
append
(
tid
)
f
(
tid
)
self
.
_storage
.
tpc_finish
(
transaction
,
func
)
return
t
[
0
]
def
__len__
(
self
):
return
len
(
self
.
_storage
)
src/ZODB/mvccadapter.py
View file @
f371a71c
...
@@ -163,15 +163,13 @@ class MVCCAdapterInstance(Base):
...
@@ -163,15 +163,13 @@ class MVCCAdapterInstance(Base):
self
.
_modified
=
set
()
self
.
_modified
=
set
()
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
s
=
s
elf
.
_storage
.
store
(
oid
,
serial
,
data
,
version
,
transaction
)
self
.
_storage
.
store
(
oid
,
serial
,
data
,
version
,
transaction
)
self
.
_modified
.
add
(
oid
)
self
.
_modified
.
add
(
oid
)
return
s
def
storeBlob
(
self
,
oid
,
serial
,
data
,
blobfilename
,
version
,
transaction
):
def
storeBlob
(
self
,
oid
,
serial
,
data
,
blobfilename
,
version
,
transaction
):
s
=
s
elf
.
_storage
.
storeBlob
(
self
.
_storage
.
storeBlob
(
oid
,
serial
,
data
,
blobfilename
,
''
,
transaction
)
oid
,
serial
,
data
,
blobfilename
,
''
,
transaction
)
self
.
_modified
.
add
(
oid
)
self
.
_modified
.
add
(
oid
)
return
s
def
tpc_finish
(
self
,
transaction
,
func
=
lambda
tid
:
None
):
def
tpc_finish
(
self
,
transaction
,
func
=
lambda
tid
:
None
):
modified
=
self
.
_modified
modified
=
self
.
_modified
...
@@ -253,11 +251,7 @@ class UndoAdapterInstance(Base):
...
@@ -253,11 +251,7 @@ class UndoAdapterInstance(Base):
def
tpc_vote
(
self
,
transaction
):
def
tpc_vote
(
self
,
transaction
):
result
=
self
.
_storage
.
tpc_vote
(
transaction
)
result
=
self
.
_storage
.
tpc_vote
(
transaction
)
if
result
:
if
result
:
if
isinstance
(
next
(
iter
(
result
)),
bytes
):
self
.
_undone
.
update
(
result
)
self
.
_undone
.
update
(
result
)
else
:
for
oid
,
_
in
result
:
self
.
_undone
.
add
(
oid
)
def
tpc_finish
(
self
,
transaction
,
func
=
lambda
tid
:
None
):
def
tpc_finish
(
self
,
transaction
,
func
=
lambda
tid
:
None
):
...
...
src/ZODB/tests/StorageTestBase.py
View file @
f371a71c
...
@@ -175,11 +175,9 @@ class StorageTestBase(ZODB.tests.util.TestCase):
...
@@ -175,11 +175,9 @@ class StorageTestBase(ZODB.tests.util.TestCase):
self
.
_storage
.
tpc_begin
(
t
)
self
.
_storage
.
tpc_begin
(
t
)
undo_result
=
self
.
_storage
.
undo
(
tid
,
t
)
undo_result
=
self
.
_storage
.
undo
(
tid
,
t
)
vote_result
=
self
.
_storage
.
tpc_vote
(
t
)
vote_result
=
self
.
_storage
.
tpc_vote
(
t
)
serial
=
self
.
_storage
.
tpc_finish
(
t
)
if
expected_oids
is
not
None
:
if
expected_oids
is
not
None
and
serial
is
None
:
oids
=
set
(
undo_result
[
1
])
if
undo_result
else
set
()
oids
=
list
(
undo_result
[
1
])
if
undo_result
else
[]
if
vote_result
:
oids
.
extend
(
oid
for
(
oid
,
_
)
in
vote_result
or
())
oids
.
update
(
vote_result
)
self
.
assertEqual
(
len
(
oids
),
len
(
expected_oids
),
repr
(
oids
))
self
.
assertEqual
(
oids
,
set
(
expected_oids
))
for
oid
in
expected_oids
:
return
self
.
_storage
.
tpc_finish
(
t
)
self
.
assertTrue
(
oid
in
oids
)
return
self
.
_storage
.
lastTransaction
()
src/ZODB/tests/TransactionalUndoStorage.py
View file @
f371a71c
This diff is collapsed.
Click to expand it.
src/ZODB/tests/testConnection.py
View file @
f371a71c
...
@@ -1275,6 +1275,7 @@ class StubStorage:
...
@@ -1275,6 +1275,7 @@ class StubStorage:
del
self
.
_transaction
del
self
.
_transaction
self
.
_transdata
.
clear
()
self
.
_transdata
.
clear
()
self
.
_transstored
=
[]
self
.
_transstored
=
[]
return
z64
def
load
(
self
,
oid
,
version
=
''
):
def
load
(
self
,
oid
,
version
=
''
):
if
version
!=
''
:
if
version
!=
''
:
...
@@ -1295,9 +1296,6 @@ class StubStorage:
...
@@ -1295,9 +1296,6 @@ class StubStorage:
self
.
_stored
.
append
(
oid
)
self
.
_stored
.
append
(
oid
)
self
.
_transstored
.
append
(
oid
)
self
.
_transstored
.
append
(
oid
)
self
.
_transdata
[
oid
]
=
(
p
,
serial
)
self
.
_transdata
[
oid
]
=
(
p
,
serial
)
# Explicitly returning None, as we're not pretending to be a ZEO
# storage
return
None
def
lastTransaction
(
self
):
def
lastTransaction
(
self
):
return
z64
return
z64
...
...
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