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
0278f361
Commit
0278f361
authored
Jun 17, 2016
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert load calls to load_current
parent
1e783423
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
103 additions
and
89 deletions
+103
-89
src/ZODB/BaseStorage.py
src/ZODB/BaseStorage.py
+2
-11
src/ZODB/FileStorage/tests.py
src/ZODB/FileStorage/tests.py
+2
-1
src/ZODB/blob.py
src/ZODB/blob.py
+1
-1
src/ZODB/scripts/fsrefs.py
src/ZODB/scripts/fsrefs.py
+3
-3
src/ZODB/scripts/netspace.py
src/ZODB/scripts/netspace.py
+3
-3
src/ZODB/scripts/space.py
src/ZODB/scripts/space.py
+2
-2
src/ZODB/tests/BasicStorage.py
src/ZODB/tests/BasicStorage.py
+13
-11
src/ZODB/tests/ConflictResolution.py
src/ZODB/tests/ConflictResolution.py
+3
-1
src/ZODB/tests/Corruption.py
src/ZODB/tests/Corruption.py
+4
-1
src/ZODB/tests/IteratorStorage.py
src/ZODB/tests/IteratorStorage.py
+2
-2
src/ZODB/tests/MTStorage.py
src/ZODB/tests/MTStorage.py
+4
-2
src/ZODB/tests/PackableStorage.py
src/ZODB/tests/PackableStorage.py
+10
-9
src/ZODB/tests/PersistentStorage.py
src/ZODB/tests/PersistentStorage.py
+4
-2
src/ZODB/tests/ReadOnlyStorage.py
src/ZODB/tests/ReadOnlyStorage.py
+3
-1
src/ZODB/tests/RecoveryStorage.py
src/ZODB/tests/RecoveryStorage.py
+3
-1
src/ZODB/tests/RevisionStorage.py
src/ZODB/tests/RevisionStorage.py
+3
-3
src/ZODB/tests/TransactionalUndoStorage.py
src/ZODB/tests/TransactionalUndoStorage.py
+24
-24
src/ZODB/tests/testDemoStorage.py
src/ZODB/tests/testDemoStorage.py
+7
-4
src/ZODB/tests/testFileStorage.py
src/ZODB/tests/testFileStorage.py
+6
-5
src/ZODB/tests/testblob.py
src/ZODB/tests/testblob.py
+4
-2
No files found.
src/ZODB/BaseStorage.py
View file @
0278f361
...
...
@@ -28,7 +28,7 @@ from persistent.TimeStamp import TimeStamp
import
ZODB.interfaces
from
.
import
POSException
,
utils
from
.utils
import
z64
,
oid_repr
,
byte_ord
,
byte_chr
from
.utils
import
z64
,
oid_repr
,
byte_ord
,
byte_chr
,
load_current
from
.UndoLogCompatible
import
UndoLogCompatible
from
._compat
import
dumps
,
_protocol
,
py2_hasattr
...
...
@@ -275,16 +275,7 @@ class BaseStorage(UndoLogCompatible):
def
getTid
(
self
,
oid
):
self
.
_lock_acquire
()
try
:
v
=
''
try
:
supportsVersions
=
self
.
supportsVersions
except
AttributeError
:
pass
else
:
if
supportsVersions
():
v
=
self
.
modifiedInVersion
(
oid
)
pickledata
,
serial
=
self
.
load
(
oid
,
v
)
return
serial
return
load_current
(
self
,
oid
)[
1
]
finally
:
self
.
_lock_release
()
...
...
src/ZODB/FileStorage/tests.py
View file @
0278f361
...
...
@@ -119,7 +119,8 @@ def pack_with_repeated_blob_records():
>>> transaction.commit()
>>> tm = transaction.TransactionManager()
>>> oid = conn.root()[1]._p_oid
>>> blob_record, oldserial = fs.load(oid)
>>> from ZODB.utils import load_current
>>> blob_record, oldserial = load_current(fs, oid)
Now, create a transaction with multiple saves:
...
...
src/ZODB/blob.py
View file @
0278f361
...
...
@@ -796,7 +796,7 @@ class BlobStorage(BlobStorageMixin):
for
oid
,
oid_path
in
self
.
fshelper
.
listOIDs
():
exists
=
True
try
:
self
.
load
(
oid
,
None
)
# no version support
utils
.
load_current
(
self
,
oid
)
# no version support
except
(
POSKeyError
,
KeyError
):
exists
=
False
...
...
src/ZODB/scripts/fsrefs.py
View file @
0278f361
...
...
@@ -66,7 +66,7 @@ import traceback
from
ZODB.FileStorage
import
FileStorage
from
ZODB.TimeStamp
import
TimeStamp
from
ZODB.utils
import
u64
,
oid_repr
,
get_pickle_metadata
from
ZODB.utils
import
u64
,
oid_repr
,
get_pickle_metadata
,
load_current
from
ZODB.serialize
import
get_refs
from
ZODB.POSException
import
POSKeyError
...
...
@@ -120,7 +120,7 @@ def main(path=None):
for
oid
in
fs
.
_index
.
keys
():
try
:
data
,
serial
=
fs
.
load
(
oid
,
""
)
data
,
serial
=
load_current
(
fs
,
oid
)
except
(
KeyboardInterrupt
,
SystemExit
):
raise
except
POSKeyError
:
...
...
@@ -135,7 +135,7 @@ def main(path=None):
for
oid
in
fs
.
_index
.
keys
():
if
oid
in
inactive
:
continue
data
,
serial
=
fs
.
load
(
oid
,
""
)
data
,
serial
=
load_current
(
fs
,
oid
)
refs
=
get_refs
(
data
)
missing
=
[]
# contains 3-tuples of oid, klass-metadata, reason
for
ref
,
klass
in
refs
:
...
...
src/ZODB/scripts/netspace.py
View file @
0278f361
...
...
@@ -9,7 +9,7 @@ usage: netspace.py [-P | -v] data.fs
from
__future__
import
print_function
import
ZODB
from
ZODB.FileStorage
import
FileStorage
from
ZODB.utils
import
U64
,
get_pickle_metadata
from
ZODB.utils
import
U64
,
get_pickle_metadata
,
load_current
from
ZODB.serialize
import
referencesf
from
six.moves
import
filter
...
...
@@ -64,7 +64,7 @@ def main(path):
v
=
cache
.
get
(
oid
)
if
v
is
not
None
:
return
v
data
,
serialno
=
fs
.
load
(
oid
,
''
)
data
,
serialno
=
load_current
(
fs
,
oid
)
size
=
len
(
data
)
for
suboid
in
referencesf
(
data
):
if
suboid
in
seen
:
...
...
@@ -89,7 +89,7 @@ def main(path):
fmt
=
"%8s %5d %8d %s %s.%s"
for
oid
in
keys
:
data
,
serialno
=
fs
.
load
(
oid
,
''
)
data
,
serialno
=
load_current
(
fs
,
oid
)
mod
,
klass
=
get_pickle_metadata
(
data
)
refs
=
referencesf
(
data
)
path
=
paths
.
get
(
oid
,
'-'
)
...
...
src/ZODB/scripts/space.py
View file @
0278f361
...
...
@@ -9,7 +9,7 @@ Current limitations / simplifications: Ignores revisions and versions.
"""
from
__future__
import
print_function
from
ZODB.FileStorage
import
FileStorage
from
ZODB.utils
import
U64
,
get_pickle_metadata
from
ZODB.utils
import
U64
,
get_pickle_metadata
,
load_current
import
six
def
run
(
path
,
v
=
0
):
...
...
@@ -21,7 +21,7 @@ def run(path, v=0):
iter
=
fs
.
_index
.
keys
()
totals
=
{}
for
oid
in
iter
:
data
,
serialno
=
fs
.
load
(
oid
,
''
)
data
,
serialno
=
load_current
(
fs
,
oid
)
mod
,
klass
=
get_pickle_metadata
(
data
)
key
=
"%s.%s"
%
(
mod
,
klass
)
bytes
,
count
=
totals
.
get
(
key
,
(
0
,
0
))
...
...
src/ZODB/tests/BasicStorage.py
View file @
0278f361
...
...
@@ -73,7 +73,7 @@ class BasicStorage:
r2
=
self
.
_storage
.
tpc_vote
(
txn
)
self
.
_storage
.
tpc_finish
(
txn
)
newrevid
=
handle_serials
(
oid
,
r1
,
r2
)
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
utils
.
load_current
(
self
.
_storage
,
oid
)
value
=
zodb_unpickle
(
data
)
eq
(
value
,
MinPO
(
11
))
eq
(
revid
,
newrevid
)
...
...
@@ -88,14 +88,14 @@ class BasicStorage:
eq
=
self
.
assertEqual
oid
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid
=
oid
,
data
=
MinPO
(
7
))
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
utils
.
load_current
(
self
.
_storage
,
oid
)
value
=
zodb_unpickle
(
data
)
eq
(
value
,
MinPO
(
7
))
# Now do a bunch of updates to an object
for
i
in
range
(
13
,
22
):
revid
=
self
.
_dostore
(
oid
,
revid
=
revid
,
data
=
MinPO
(
i
))
# Now get the latest revision of the object
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
utils
.
load_current
(
self
.
_storage
,
oid
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
21
))
def
checkConflicts
(
self
):
...
...
@@ -132,7 +132,7 @@ class BasicStorage:
revid
=
self
.
_dostore
(
oid
=
oid
,
data
=
MinPO
(
6
))
for
oid
,
revid
in
[(
oid1
,
revid1
),
(
oid
,
revid
)]:
data
,
_revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
_revid
=
utils
.
load_current
(
self
.
_storage
,
oid
)
self
.
assertEqual
(
revid
,
_revid
)
def
checkStoreTwoObjects
(
self
):
...
...
@@ -270,8 +270,10 @@ class BasicStorage:
self
.
_storage
.
tpc_finish
(
t
)
thread
.
join
(
33
)
tid3
=
self
.
_storage
.
load
(
oid
)[
1
]
self
.
assertTrue
(
tid3
>
self
.
_storage
.
load
(
b'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf3
'
)[
1
])
tid3
=
utils
.
load_current
(
self
.
_storage
,
oid
)[
1
]
self
.
assertTrue
(
tid3
>
utils
.
load_current
(
self
.
_storage
,
b'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf3
'
)[
1
])
#----------------------------------------------------------------------
# non-stale competing trans after checkCurrentSerialInTransaction
...
...
@@ -296,9 +298,10 @@ class BasicStorage:
else
:
self
.
_storage
.
tpc_finish
(
t
)
thread
.
join
()
tid4
=
self
.
_storage
.
load
(
oid
)[
1
]
self
.
assertTrue
(
tid4
>
self
.
_storage
.
load
(
b'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf4
'
)[
1
])
tid4
=
utils
.
load_current
(
self
.
_storage
,
oid
)[
1
]
self
.
assertTrue
(
tid4
>
utils
.
load_current
(
self
.
_storage
,
b'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf4
'
)[
1
])
def
check_tid_ordering_w_commit
(
self
):
...
...
@@ -363,7 +366,7 @@ class BasicStorage:
@
run_in_thread
def
load
():
update_attempts
()
results
[
'load'
]
=
self
.
_storage
.
load
(
ZERO
,
''
)[
1
]
results
[
'load'
]
=
utils
.
load_current
(
self
.
_storage
,
ZERO
)[
1
]
expected_attempts
=
2
...
...
@@ -397,4 +400,3 @@ class BasicStorage:
self
.
assertEqual
(
results
.
pop
(
'lastTransaction'
),
tids
[
1
])
for
m
,
tid
in
results
.
items
():
self
.
assertEqual
(
tid
,
tids
[
1
])
src/ZODB/tests/ConflictResolution.py
View file @
0278f361
...
...
@@ -17,6 +17,8 @@ from ZODB.POSException import ConflictError, UndoError
from
persistent
import
Persistent
from
transaction
import
Transaction
from
ZODB.utils
import
load_current
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
,
zodb_pickle
class
PCounter
(
Persistent
):
...
...
@@ -71,7 +73,7 @@ class ConflictResolvingStorage:
revid2
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
revid3
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
data
,
serialno
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
serialno
=
load_current
(
self
.
_storage
,
oid
)
inst
=
zodb_unpickle
(
data
)
self
.
assertEqual
(
inst
.
_value
,
5
)
...
...
src/ZODB/tests/Corruption.py
View file @
0278f361
...
...
@@ -18,6 +18,9 @@ import random
import
stat
import
ZODB.FileStorage
from
ZODB.utils
import
load_current
from
.StorageTestBase
import
StorageTestBase
class
FileStorageCorruptTests
(
StorageTestBase
):
...
...
@@ -36,7 +39,7 @@ class FileStorageCorruptTests(StorageTestBase):
def
_check_stores
(
self
,
oids
):
for
oid
,
revid
in
oids
:
data
,
s_revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
s_revid
=
load_current
(
self
.
_storage
,
oid
)
self
.
assertEqual
(
s_revid
,
revid
)
def
checkTruncatedIndex
(
self
):
...
...
src/ZODB/tests/IteratorStorage.py
View file @
0278f361
...
...
@@ -20,7 +20,7 @@ all these tests.
from
ZODB.tests.MinPO
import
MinPO
from
ZODB.tests.StorageTestBase
import
zodb_pickle
,
zodb_unpickle
from
ZODB.utils
import
U64
,
p64
from
ZODB.utils
import
U64
,
p64
,
load_current
from
transaction
import
Transaction
...
...
@@ -122,7 +122,7 @@ class IteratorStorage(IteratorCompare):
def
checkLoad_was_checkLoadEx
(
self
):
oid
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid
,
data
=
42
)
data
,
tid
=
self
.
_storage
.
load
(
oid
,
""
)
data
,
tid
=
load_current
(
self
.
_storage
,
oid
)
self
.
assertEqual
(
zodb_unpickle
(
data
),
MinPO
(
42
))
match
=
False
for
txn
in
self
.
_storage
.
iterator
():
...
...
src/ZODB/tests/MTStorage.py
View file @
0278f361
...
...
@@ -13,6 +13,8 @@ from ZODB.tests.StorageTestBase import handle_serials
from
ZODB.tests.MinPO
import
MinPO
from
ZODB.POSException
import
ConflictError
from
ZODB.utils
import
load_current
SHORT_DELAY
=
0.01
class
TestThread
(
threading
.
Thread
):
...
...
@@ -124,7 +126,7 @@ class StorageClientThread(TestThread):
def
check
(
self
):
for
oid
,
revid
in
self
.
oids
.
items
():
data
,
serial
=
self
.
storage
.
load
(
oid
,
''
)
data
,
serial
=
load_current
(
self
.
storage
,
oid
)
self
.
test
.
assertEqual
(
serial
,
revid
)
obj
=
zodb_unpickle
(
data
)
self
.
test
.
assertEqual
(
obj
.
value
[
0
],
self
.
getName
())
...
...
@@ -192,7 +194,7 @@ class ExtStorageClientThread(StorageClientThread):
def
do_load
(
self
):
oid
=
self
.
pick_oid
()
self
.
storage
.
load
(
oid
,
''
)
load_current
(
self
.
storage
,
oid
)
def
do_loadSerial
(
self
):
oid
=
self
.
pick_oid
()
...
...
src/ZODB/tests/PackableStorage.py
View file @
0278f361
...
...
@@ -32,6 +32,7 @@ import ZODB.interfaces
import
ZODB.tests.util
import
zope.testing.setupstack
from
ZODB.utils
import
load_current
ZERO
=
b'
\
0
'
*
8
...
...
@@ -141,7 +142,7 @@ class PackableStorageBase:
def
_initroot
(
self
):
try
:
self
.
_storage
.
load
(
ZERO
,
''
)
load_current
(
self
.
_storage
,
ZERO
)
except
KeyError
:
from
transaction
import
Transaction
file
=
BytesIO
()
...
...
@@ -393,7 +394,7 @@ class PackableStorage(PackableStorageBase):
root
.
value
=
0
revid0
=
self
.
_dostoreNP
(
ZERO
,
data
=
dumps
(
root
))
# Make sure the root can be retrieved
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
ZERO
)
eq
(
revid
,
revid0
)
eq
(
loads
(
data
).
value
,
0
)
# Commit three different revisions of the other object
...
...
@@ -424,7 +425,7 @@ class PackableStorage(PackableStorageBase):
self
.
_storage
.
pack
(
packtime
,
referencesf
)
# Make sure the revisions are gone, but that object zero and revision
# 3 are still there and correct
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
ZERO
)
eq
(
revid
,
revid0
)
eq
(
loads
(
data
).
value
,
0
)
raises
(
KeyError
,
self
.
_storage
.
loadSerial
,
oid
,
revid1
)
...
...
@@ -433,7 +434,7 @@ class PackableStorage(PackableStorageBase):
pobj
=
loads
(
data
)
eq
(
pobj
.
getoid
(),
oid
)
eq
(
pobj
.
value
,
3
)
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid
)
eq
(
revid
,
revid3
)
pobj
=
loads
(
data
)
eq
(
pobj
.
getoid
(),
oid
)
...
...
@@ -461,7 +462,7 @@ class PackableStorage(PackableStorageBase):
root
.
value
=
0
revid0
=
self
.
_dostoreNP
(
ZERO
,
data
=
dumps
(
root
))
# Make sure the root can be retrieved
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
ZERO
)
eq
(
revid
,
revid0
)
eq
(
loads
(
data
).
value
,
0
)
# Commit three different revisions of the first object
...
...
@@ -501,7 +502,7 @@ class PackableStorage(PackableStorageBase):
self
.
_storage
.
pack
(
packtime
,
referencesf
)
# Make sure the revisions are gone, but that object zero, object2, and
# revision 3 of object1 are still there and correct.
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
ZERO
)
eq
(
revid
,
revid0
)
eq
(
loads
(
data
).
value
,
0
)
raises
(
KeyError
,
self
.
_storage
.
loadSerial
,
oid1
,
revid1
)
...
...
@@ -510,12 +511,12 @@ class PackableStorage(PackableStorageBase):
pobj
=
loads
(
data
)
eq
(
pobj
.
getoid
(),
oid1
)
eq
(
pobj
.
value
,
3
)
data
,
revid
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid1
)
eq
(
revid
,
revid3
)
pobj
=
loads
(
data
)
eq
(
pobj
.
getoid
(),
oid1
)
eq
(
pobj
.
value
,
3
)
data
,
revid
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid2
)
eq
(
revid
,
revid4
)
eq
(
loads
(
data
).
value
,
11
)
data
=
self
.
_storage
.
loadSerial
(
oid2
,
revid4
)
...
...
@@ -649,7 +650,7 @@ class PackableUndoStorage(PackableStorageBase):
pass
# This object would be removed by the second pack, even though
# it is reachable.
self
.
_storage
.
load
(
lost_oid
,
""
)
load_current
(
self
.
_storage
,
lost_oid
)
def
checkPackUndoLog
(
self
):
self
.
_initroot
()
...
...
src/ZODB/tests/PersistentStorage.py
View file @
0278f361
...
...
@@ -13,6 +13,8 @@
##############################################################################
"""Test that a storage's values persist across open and close."""
from
ZODB.utils
import
load_current
class
PersistentStorage
:
def
checkUpdatesPersist
(
self
):
...
...
@@ -36,7 +38,7 @@ class PersistentStorage:
# keep copies of all the objects
objects
=
[]
for
oid
in
oids
:
p
,
s
=
self
.
_storage
.
load
(
oid
,
''
)
p
,
s
=
load_current
(
self
.
_storage
,
oid
)
objects
.
append
((
oid
,
''
,
p
,
s
))
self
.
_storage
.
close
()
...
...
@@ -44,6 +46,6 @@ class PersistentStorage:
# keep copies of all the objects
for
oid
,
ver
,
p
,
s
in
objects
:
_p
,
_s
=
self
.
_storage
.
load
(
oid
,
ver
)
_p
,
_s
=
load_current
(
self
.
_storage
,
oid
)
self
.
assertEqual
(
p
,
_p
)
self
.
assertEqual
(
s
,
_s
)
src/ZODB/tests/ReadOnlyStorage.py
View file @
0278f361
...
...
@@ -14,6 +14,8 @@
from
ZODB.POSException
import
ReadOnlyError
,
Unsupported
import
transaction
from
ZODB.utils
import
load_current
class
ReadOnlyStorage
:
def
_create_data
(
self
):
...
...
@@ -34,7 +36,7 @@ class ReadOnlyStorage:
self
.
_make_readonly
()
# Note that this doesn't check _all_ read methods.
for
oid
in
self
.
oids
.
keys
():
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid
)
self
.
assertEqual
(
revid
,
self
.
oids
[
oid
])
# Storages without revisions may not have loadSerial().
try
:
...
...
src/ZODB/tests/RecoveryStorage.py
View file @
0278f361
...
...
@@ -20,6 +20,8 @@ from ZODB.tests.StorageTestBase import MinPO, snooze
from
ZODB
import
DB
from
ZODB.serialize
import
referencesf
from
ZODB.utils
import
load_current
import
time
...
...
@@ -88,7 +90,7 @@ class RecoveryStorage(IteratorDeepCompare):
self
.
_dst
.
pack
(
time
.
time
(),
referencesf
)
# And check to see that the root object exists, but not the other
# objects.
data
,
serial
=
self
.
_dst
.
load
(
root
.
_p_oid
,
''
)
data
,
serial
=
load_current
(
self
.
_dst
,
root
.
_p_oid
)
raises
(
KeyError
,
self
.
_dst
.
load
,
obj1
.
_p_oid
,
''
)
raises
(
KeyError
,
self
.
_dst
.
load
,
obj2
.
_p_oid
,
''
)
...
...
src/ZODB/tests/RevisionStorage.py
View file @
0278f361
...
...
@@ -16,7 +16,7 @@
from
ZODB.tests.MinPO
import
MinPO
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
,
zodb_pickle
,
snooze
from
ZODB.tests.StorageTestBase
import
handle_serials
from
ZODB.utils
import
p64
,
u64
from
ZODB.utils
import
p64
,
u64
,
load_current
import
transaction
...
...
@@ -52,7 +52,7 @@ class RevisionStorage:
snooze
()
snooze
()
revid
=
self
.
_dostore
(
oid
,
revid
,
data
=
MinPO
(
i
))
revs
.
append
(
self
.
_storage
.
load
(
oid
,
""
))
revs
.
append
(
load_current
(
self
.
_storage
,
oid
))
prev
=
u64
(
revs
[
0
][
1
])
for
i
in
range
(
1
,
10
):
...
...
@@ -123,7 +123,7 @@ class RevisionStorage:
# Always undo the most recent txn, so the value will
# alternate between 3 and 4.
self
.
_undo
(
tid
,
note
=
"undo %d"
%
i
)
revs
.
append
(
self
.
_storage
.
load
(
oid
,
""
))
revs
.
append
(
load_current
(
self
.
_storage
,
oid
))
prev_tid
=
None
for
i
,
(
data
,
tid
)
in
enumerate
(
revs
):
...
...
src/ZODB/tests/TransactionalUndoStorage.py
View file @
0278f361
...
...
@@ -23,7 +23,7 @@ from transaction import Transaction
from
ZODB
import
POSException
from
ZODB.serialize
import
referencesf
from
ZODB.utils
import
p64
from
ZODB.utils
import
p64
,
load_current
from
ZODB
import
DB
from
ZODB.tests.MinPO
import
MinPO
...
...
@@ -125,13 +125,13 @@ class TransactionalUndoStorage:
info
=
self
.
_storage
.
undoInfo
()
# Now start an undo transaction
self
.
_undo
(
info
[
0
][
"id"
],
[
oid
],
note
=
"undo1"
)
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
24
))
# Do another one
info
=
self
.
_storage
.
undoInfo
()
self
.
_undo
(
info
[
2
][
"id"
],
[
oid
],
note
=
"undo2"
)
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
23
))
# Try to undo the first record
...
...
@@ -144,7 +144,7 @@ class TransactionalUndoStorage:
# And now let's try to redo the object's creation
info
=
self
.
_storage
.
undoInfo
()
self
.
_undo
(
info
[
0
][
"id"
],
[
oid
])
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
23
))
self
.
_iterate
()
...
...
@@ -171,7 +171,7 @@ class TransactionalUndoStorage:
# Undo the last transaction
info
=
self
.
_storage
.
undoInfo
()
self
.
_undo
(
info
[
0
][
'id'
],
[
oid
])
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
11
))
# Now from here, we can either redo the last undo, or undo the object
...
...
@@ -193,13 +193,13 @@ class TransactionalUndoStorage:
# Undo the last transaction
info
=
self
.
_storage
.
undoInfo
()
self
.
_undo
(
info
[
0
][
'id'
],
[
oid
])
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
11
))
# Now from here, we can either redo the last undo, or undo the object
# creation. Let's redo the last undo
info
=
self
.
_storage
.
undoInfo
()
self
.
_undo
(
info
[
0
][
'id'
],
[
oid
])
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
12
))
self
.
_iterate
()
...
...
@@ -236,17 +236,17 @@ class TransactionalUndoStorage:
self
.
_storage
.
tpc_finish
(
t
)
eq
(
revid1
,
revid2
)
# Make sure the objects have the current value
data
,
revid1
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid1
=
load_current
(
self
.
_storage
,
oid1
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
32
))
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid2
=
load_current
(
self
.
_storage
,
oid2
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
52
))
# Now attempt to undo the transaction containing two objects
info
=
self
.
_storage
.
undoInfo
()
self
.
_undo
(
info
[
0
][
'id'
],
[
oid1
,
oid2
])
data
,
revid1
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid1
=
load_current
(
self
.
_storage
,
oid1
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
31
))
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid2
=
load_current
(
self
.
_storage
,
oid2
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
51
))
self
.
_iterate
()
...
...
@@ -279,9 +279,9 @@ class TransactionalUndoStorage:
revid2
=
self
.
_transaction_newserial
(
oid2
)
eq
(
revid1
,
revid2
)
# Make sure the objects have the current value
data
,
revid1
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid1
=
load_current
(
self
.
_storage
,
oid1
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
32
))
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid2
=
load_current
(
self
.
_storage
,
oid2
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
52
))
# Now attempt to undo the transaction containing two objects
info
=
self
.
_storage
.
undoInfo
()
...
...
@@ -293,17 +293,17 @@ class TransactionalUndoStorage:
# We may get the finalization stuff called an extra time,
# depending on the implementation.
self
.
assertEqual
(
set
(
oids
),
set
((
oid1
,
oid2
)))
data
,
revid1
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid1
=
load_current
(
self
.
_storage
,
oid1
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
30
))
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid2
=
load_current
(
self
.
_storage
,
oid2
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
50
))
# Now try to undo the one we just did to undo, whew
info
=
self
.
_storage
.
undoInfo
()
self
.
_undo
(
info
[
0
][
'id'
],
[
oid1
,
oid2
])
data
,
revid1
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid1
=
load_current
(
self
.
_storage
,
oid1
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
32
))
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid2
=
load_current
(
self
.
_storage
,
oid2
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
52
))
self
.
_iterate
()
...
...
@@ -333,9 +333,9 @@ class TransactionalUndoStorage:
# Now attempt to undo the transaction containing two objects
info
=
self
.
_storage
.
undoInfo
()
self
.
_undo
(
info
[
0
][
"id"
],
[
oid1
,
oid2
])
data
,
revid1
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid1
=
load_current
(
self
.
_storage
,
oid1
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
31
))
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid2
=
load_current
(
self
.
_storage
,
oid2
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
51
))
# Like the above, but this time, the second transaction contains only
# one object.
...
...
@@ -362,9 +362,9 @@ class TransactionalUndoStorage:
eq
(
len
(
oids
),
1
)
self
.
assertTrue
(
oid1
in
oids
)
self
.
assertTrue
(
not
oid2
in
oids
)
data
,
revid1
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid1
=
load_current
(
self
.
_storage
,
oid1
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
33
))
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid2
=
load_current
(
self
.
_storage
,
oid2
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
54
))
self
.
_iterate
()
...
...
@@ -403,9 +403,9 @@ class TransactionalUndoStorage:
revid2
=
self
.
_transaction_newserial
(
oid2
)
eq
(
revid1
,
revid2
)
# Make sure the objects have the expected values
data
,
revid_11
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid_11
=
load_current
(
self
.
_storage
,
oid1
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
81
))
data
,
revid_22
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid_22
=
load_current
(
self
.
_storage
,
oid2
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
91
))
eq
(
revid_11
,
revid1
)
eq
(
revid_22
,
revid2
)
...
...
@@ -461,7 +461,7 @@ class TransactionalUndoStorage:
self
.
_storage
.
tpc_finish
(
t
)
self
.
assertEqual
(
len
(
oids
),
1
)
self
.
assertEqual
(
oids
[
0
],
oid
)
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
load_current
(
self
.
_storage
,
oid
)
# The object must now be at the second state
self
.
assertEqual
(
zodb_unpickle
(
data
),
MinPO
(
52
))
self
.
_iterate
()
...
...
src/ZODB/tests/testDemoStorage.py
View file @
0278f361
...
...
@@ -37,6 +37,9 @@ import ZODB.DemoStorage
import
ZODB.tests.hexstorage
import
ZODB.tests.util
import
ZODB.utils
from
ZODB.utils
import
load_current
from
zope.testing
import
renormalizing
...
...
@@ -67,8 +70,8 @@ class DemoStorageTests(
# Minimal test of loadEX w/o version -- ironically
db
=
DB
(
self
.
_storage
)
# creates object 0. :)
s2
=
ZODB
.
DemoStorage
.
DemoStorage
(
base
=
self
.
_storage
)
self
.
assertEqual
(
s2
.
load
(
ZODB
.
utils
.
z64
,
''
),
self
.
_storage
.
load
(
ZODB
.
utils
.
z64
,
''
))
self
.
assertEqual
(
load_current
(
s2
,
ZODB
.
utils
.
z64
),
load_current
(
self
.
_storage
,
ZODB
.
utils
.
z64
))
def
checkLengthAndBool
(
self
):
self
.
assertEqual
(
len
(
self
.
_storage
),
0
)
...
...
@@ -238,7 +241,7 @@ def load_before_base_storage_current():
>>> transaction.commit()
>>> oid = ZODB.utils.z64
>>> base_current =
storage.base.load(
oid)
>>> base_current =
load_current(storage.base,
oid)
>>> tid = ZODB.utils.p64(ZODB.utils.u64(base_current[1]) + 1)
>>> base_record = storage.base.loadBefore(oid, tid)
>>> base_record[-1] is None
...
...
@@ -253,7 +256,7 @@ def load_before_base_storage_current():
>>> t[:2] == base_record[:2]
True
>>> t[-1] ==
storage.changes.load(
oid)[1]
>>> t[-1] ==
load_current(storage.changes,
oid)[1]
True
>>> conn.close()
...
...
src/ZODB/tests/testFileStorage.py
View file @
0278f361
...
...
@@ -26,7 +26,7 @@ import zope.testing.setupstack
from
ZODB
import
POSException
from
ZODB
import
DB
from
ZODB.fsIndex
import
fsIndex
from
ZODB.utils
import
U64
,
p64
,
z64
from
ZODB.utils
import
U64
,
p64
,
z64
,
load_current
from
ZODB.tests
import
StorageTestBase
,
BasicStorage
,
TransactionalUndoStorage
from
ZODB.tests
import
PackableStorage
,
Synchronization
,
ConflictResolution
...
...
@@ -279,7 +279,7 @@ class FileStorageTests(
oid
,
tid
,
data
,
next_oid
=
self
.
_storage
.
record_iternext
(
key
)
self
.
assertEqual
(
oid
,
(
b'
\
000
'
*
7
)
+
x
)
key
=
next_oid
expected_data
,
expected_tid
=
self
.
_storage
.
load
(
oid
,
''
)
expected_data
,
expected_tid
=
load_current
(
self
.
_storage
,
oid
)
self
.
assertEqual
(
expected_data
,
data
)
self
.
assertEqual
(
expected_tid
,
tid
)
if
x
==
b'
\
002
'
:
...
...
@@ -296,13 +296,14 @@ class FileStorageTests(
storage
.
tpc_vote
(
t
)
# Read operations are done with separate 'file' objects with their
# own buffers: here, the buffer also includes voted data.
storage
.
load
(
z64
)
load_current
(
storage
,
z64
)
# This must invalidate all read buffers.
storage
.
tpc_abort
(
t
)
self
.
_dostore
(
z64
,
r0
,
b'bar'
,
1
)
# In the case that read buffers were not invalidated, return value
# is based on what was cached during the first load.
self
.
assertEqual
(
storage
.
load
(
z64
)[
0
],
b'foo'
if
fail
else
b'bar'
)
self
.
assertEqual
(
load_current
(
storage
,
z64
)[
0
],
b'foo'
if
fail
else
b'bar'
)
# We want to be sure that the above test detects any regression
# in the code it checks, because any bug here is like a time bomb: not
...
...
@@ -642,7 +643,7 @@ def deal_with_finish_failures():
>>> handler.uninstall()
>>>
fs.load(b'\0'*8, b''
) # doctest: +ELLIPSIS
>>>
load_current(fs, b'\0'*8
) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ValueError: ...
...
...
src/ZODB/tests/testblob.py
View file @
0278f361
...
...
@@ -568,14 +568,16 @@ def loadblob_tmpstore():
def
is_blob_record
():
r"""
>>> from ZODB.utils import load_current
>>> bs = create_storage()
>>> db = DB(bs)
>>> conn = db.open()
>>> conn.root()['blob'] = ZODB.blob.Blob()
>>> transaction.commit()
>>> ZODB.blob.is_blob_record(
bs.load(ZODB.utils.p64(0), ''
)[0])
>>> ZODB.blob.is_blob_record(
load_current(bs, ZODB.utils.p64(0)
)[0])
False
>>> ZODB.blob.is_blob_record(
bs.load(ZODB.utils.p64(1), ''
)[0])
>>> ZODB.blob.is_blob_record(
load_current(bs, ZODB.utils.p64(1)
)[0])
True
An invalid pickle yields a false value:
...
...
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