Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tempstorage
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
tempstorage
Commits
5cc223ea
Commit
5cc223ea
authored
Sep 09, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add two fixes for ZODB, not yet fully compatible.
parent
d0c33df1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
4 deletions
+46
-4
src/tempstorage/TemporaryStorage.py
src/tempstorage/TemporaryStorage.py
+0
-3
src/tempstorage/tests/testTemporaryStorage.py
src/tempstorage/tests/testTemporaryStorage.py
+46
-1
No files found.
src/tempstorage/TemporaryStorage.py
View file @
5cc223ea
...
...
@@ -25,7 +25,6 @@ import time
from
ZODB
import
POSException
from
ZODB.BaseStorage
import
BaseStorage
from
ZODB.ConflictResolution
import
ConflictResolvingStorage
from
ZODB.ConflictResolution
import
ResolvedSerial
from
ZODB.serialize
import
referencesf
from
ZODB.utils
import
z64
...
...
@@ -219,9 +218,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
data
=
newdata
else
:
oserial
=
serial
newserial
=
self
.
_tid
self
.
_tmp
.
append
((
oid
,
data
))
return
serial
==
oserial
and
newserial
or
ResolvedSerial
def
_finish
(
self
,
tid
,
u
,
d
,
e
):
zeros
=
{}
...
...
src/tempstorage/tests/testTemporaryStorage.py
View file @
5cc223ea
...
...
@@ -21,6 +21,51 @@ from ZODB.tests import ConflictResolution
from
ZODB.tests
import
MTStorage
def
handle_all_serials
(
oid
,
*
args
):
"""Return dict of oid to serialno from store() and tpc_vote().
Raises an exception if one of the calls raised an exception.
The storage interface got complicated when ZEO was introduced.
Any individual store() call can return None or a sequence of
2-tuples where the 2-tuple is either oid, serialno or an
exception to be raised by the client.
The original interface just returned the serialno for the
object.
The updated multi-commit API returns nothing from store(), and
returns a sequence of resolved oids from tpc_vote.
NOTE: This function is removed entirely in ZODB 5.
"""
d
=
{}
for
arg
in
args
:
if
isinstance
(
arg
,
bytes
):
d
[
oid
]
=
arg
elif
arg
:
for
t
in
arg
:
if
isinstance
(
t
,
bytes
):
# New protocol. The caller will use the tid
# returned from tpc_finish if we return a dict
# missing the oid.
pass
else
:
oid
,
serial
=
t
if
not
isinstance
(
serial
,
bytes
):
raise
serial
# error from ZEO server
d
[
oid
]
=
serial
return
d
def
handle_serials
(
oid
,
*
args
):
"""Return the serialno for oid based on multiple return values.
A helper for function _handle_all_serials().
"""
return
handle_all_serials
(
oid
,
*
args
).
get
(
oid
)
class
ZODBProtocolTests
(
StorageTestBase
.
StorageTestBase
,
BasicStorage
.
BasicStorage
,
Synchronization
.
SynchronizedStorage
,
...
...
@@ -87,7 +132,7 @@ class TemporaryStorageTests(unittest.TestCase):
r1
=
storage
.
store
(
oid
,
revid
,
data
,
''
,
t
)
# Finish the transaction
r2
=
storage
.
tpc_vote
(
t
)
revid
=
StorageTestBase
.
handle_serials
(
oid
,
r1
,
r2
)
revid
=
handle_serials
(
oid
,
r1
,
r2
)
storage
.
tpc_finish
(
t
)
except
:
storage
.
tpc_abort
(
t
)
...
...
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