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
Kirill Smelkov
ZODB
Commits
398f08bb
Commit
398f08bb
authored
Apr 10, 2001
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed to use undoInfo.
parent
681d1daf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
22 deletions
+36
-22
trunk/src/ZODB/tests/TransactionalUndoStorage.py
trunk/src/ZODB/tests/TransactionalUndoStorage.py
+36
-22
No files found.
trunk/src/ZODB/tests/TransactionalUndoStorage.py
View file @
398f08bb
import
BasicStorage
,
pickle
from
ZODB
import
POSException
ZERO
=
'
\
0
'
*
8
class
UndoStorage
(
BasicStorage
.
BasicStorage
):
class
Transactional
UndoStorage
(
BasicStorage
.
BasicStorage
):
def
checkSimpleTransactionalUndo
(
self
):
oid
=
self
.
_storage
.
new_oid
()
revid
=
self
.
_dostore
(
oid
,
data
=
23
)
revid
=
self
.
_dostore
(
oid
,
revid
=
revid
,
data
=
24
)
revid
=
self
.
_dostore
(
oid
,
revid
=
revid
,
data
=
25
)
info
=
self
.
_storage
.
undoInfo
()
tid
=
info
[
0
][
'id'
]
# Now start an undo transaction
self
.
_transaction
.
note
(
'undo1'
)
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
rev
id
,
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
t
id
,
self
.
_transaction
)
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
assert
len
(
oids
)
==
1
...
...
@@ -19,8 +24,11 @@ class UndoStorage(BasicStorage.BasicStorage):
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
assert
pickle
.
loads
(
data
)
==
24
# Do another one
info
=
self
.
_storage
.
undoInfo
()
tid
=
info
[
2
][
'id'
]
self
.
_transaction
.
note
(
'undo2'
)
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
rev
id
,
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
t
id
,
self
.
_transaction
)
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
assert
len
(
oids
)
==
1
...
...
@@ -28,26 +36,24 @@ class UndoStorage(BasicStorage.BasicStorage):
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
assert
pickle
.
loads
(
data
)
==
23
# Try to undo the first record
info
=
self
.
_storage
.
undoInfo
()
tid
=
info
[
4
][
'id'
]
self
.
_transaction
.
note
(
'undo3'
)
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
rev
id
,
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
t
id
,
self
.
_transaction
)
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
assert
len
(
oids
)
==
1
assert
oids
[
0
]
==
oid
# This should fail since we've undone the object's creation
self
.
assertRaises
(
KeyError
,
self
.
_storage
.
load
,
oid
,
''
)
# But it's really a more specific type of error
import
Full
self
.
assertRaises
(
Full
.
ObjectDoesNotExist
,
self
.
_storage
.
load
,
oid
,
''
)
# And now let's try to redo the object's creation
try
:
self
.
_storage
.
load
(
oid
,
''
)
except
Full
.
ObjectDoesNotExist
,
e
:
revid
=
e
.
revid
info
=
self
.
_storage
.
undoInfo
()
tid
=
info
[
0
][
'id'
]
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
rev
id
,
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
t
id
,
self
.
_transaction
)
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
assert
len
(
oids
)
==
1
...
...
@@ -83,8 +89,10 @@ class UndoStorage(BasicStorage.BasicStorage):
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
assert
pickle
.
loads
(
data
)
==
52
# Now attempt to undo the transaction containing two objects
info
=
self
.
_storage
.
undoInfo
()
tid
=
info
[
0
][
'id'
]
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
revid1
,
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
tid
,
self
.
_transaction
)
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
assert
len
(
oids
)
==
2
...
...
@@ -94,7 +102,7 @@ class UndoStorage(BasicStorage.BasicStorage):
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
assert
pickle
.
loads
(
data
)
==
51
def
checkTwoObjectUndoAgain
(
self
):
def
_
checkTwoObjectUndoAgain
(
self
):
p32
,
p33
,
p52
,
p53
=
map
(
pickle
.
dumps
,
(
32
,
33
,
52
,
53
))
# Like the above, but the first revision of the objects are stored in
# different transactions.
...
...
@@ -111,8 +119,10 @@ class UndoStorage(BasicStorage.BasicStorage):
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
assert
revid1
==
revid2
# Now attempt to undo the transaction containing two objects
info
=
self
.
_storage
.
undoInfo
()
tid
=
info
[
0
][
'id'
]
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
revid1
,
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
tid
,
self
.
_transaction
)
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
assert
len
(
oids
)
==
2
...
...
@@ -134,8 +144,10 @@ class UndoStorage(BasicStorage.BasicStorage):
revid1
=
self
.
_dostore
(
oid1
,
revid
=
revid1
,
data
=
34
)
revid2
=
self
.
_dostore
(
oid2
,
revid
=
revid2
,
data
=
54
)
# Now attempt to undo the transaction containing two objects
info
=
self
.
_storage
.
undoInfo
()
tid
=
info
[
1
][
'id'
]
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
revid1
,
self
.
_transaction
)
oids
=
self
.
_storage
.
transactionalUndo
(
tid
,
self
.
_transaction
)
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
assert
len
(
oids
)
==
1
...
...
@@ -152,10 +164,12 @@ class UndoStorage(BasicStorage.BasicStorage):
revid_b
=
self
.
_dostore
(
oid
,
revid
=
revid_a
,
data
=
52
)
revid_c
=
self
.
_dostore
(
oid
,
revid
=
revid_b
,
data
=
53
)
# Start the undo
info
=
self
.
_storage
.
undoInfo
()
tid
=
info
[
1
][
'id'
]
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
assertRaises
(
POSException
.
UndoError
,
self
.
_storage
.
transactionalUndo
,
revid_b
,
self
.
_transaction
)
tid
,
self
.
_transaction
)
self
.
_storage
.
tpc_abort
(
self
.
_transaction
)
# Now have more fun: object1 and object2 are in the same transaction,
# which we'll try to undo to, but one of them has since modified in
...
...
@@ -165,6 +179,7 @@ class UndoStorage(BasicStorage.BasicStorage):
oid2
=
self
.
_storage
.
new_oid
()
revid2
=
ZERO
p81
,
p82
,
p91
,
p92
=
map
(
pickle
.
dumps
,
(
81
,
82
,
91
,
92
))
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
revid1
=
self
.
_storage
.
store
(
oid1
,
revid1
,
p81
,
''
,
self
.
_transaction
)
revid2
=
self
.
_storage
.
store
(
oid2
,
revid2
,
p91
,
''
,
self
.
_transaction
)
...
...
@@ -180,11 +195,10 @@ class UndoStorage(BasicStorage.BasicStorage):
# Now modify oid2
revid2
=
self
.
_dostore
(
oid2
,
revid
=
revid2
,
data
=
p92
)
assert
revid1
<>
revid2
and
revid2
<>
revid_22
info
=
self
.
_storage
.
undoInfo
()
tid
=
info
[
1
][
'id'
]
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
assertRaises
(
POSException
.
UndoError
,
self
.
_storage
.
transactionalUndo
,
revid1
,
self
.
_transaction
)
self
.
assertRaises
(
POSException
.
UndoError
,
self
.
_storage
.
transactionalUndo
,
revid_22
,
self
.
_transaction
)
tid
,
self
.
_transaction
)
self
.
_storage
.
tpc_abort
(
self
.
_transaction
)
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