Commit c59a54ca authored by Kirill Smelkov's avatar Kirill Smelkov

Drop support for ZODB3

Nexedi stack is dropping support for that old ZODB version - see e.g.

- slapos@70d05199
- neoppod@3a8f6f03
- wendelin.core@0802da2b

Regarding test/gen_testdata.py: even though ZODB4 uses zodbpickle, and
so should be able to load pickles encoded with protocol 3 even on
python2, in practice it does not work so well: ZODB4 tests fail if I set

    --- a/src/ZODB/_compat.py
    +++ b/src/ZODB/_compat.py
    @@ -34,7 +34,7 @@
         HIGHEST_PROTOCOL = cPickle.HIGHEST_PROTOCOL
         IMPORT_MAPPING = {}
         NAME_MAPPING = {}
    -    _protocol = 1
    +    _protocol = 3
         FILESTORAGE_MAGIC = b"FS21"
     else:
         # Python 3.x: can't use stdlib's pickle because

-> so continue to preserve protocol < 3 when generating the test
database for compatibility - now with ZODB4/py2.

/reviewed-by @jerome
/reviewed-on !18
parent 986baf02
Pipeline #14131 passed with stage
in 0 seconds
# zodbtools | tox setup # zodbtools | tox setup
[tox] [tox]
envlist = py27-ZODB3, py{27,36,37}-ZODB{4,5} envlist = py{27,36,37}-ZODB{4,5}
[testenv] [testenv]
deps = deps =
.[test] .[test]
# latest ZODB from ZODB3 series
ZODB3: ZODB3 >=3.10, <3.11dev
ZODB3: transaction <2.0dev
# ZConfig 3.2.0 passes filename to ZEO config as unicode which eventualy breaks in FileStorage:
# https://github.com/zopefoundation/ZODB/blob/3.10.7-4-gb8d7a8567/src/ZODB/FileStorage/FileStorage.py#L1640
ZODB3: ZConfig <3.2.0
# latest current ZODB 4 # latest current ZODB 4
ZODB4: ZODB >=4.0, <5.0dev ZODB4: ZODB >=4.0, <5.0dev
ZODB4: ZEO >=4.0, <5.0dev ZODB4: ZEO >=4.0, <5.0dev
......
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2017-2020 Nexedi SA and Contributors. # Copyright (C) 2017-2021 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com> # Kirill Smelkov <kirr@nexedi.com>
# #
# This program is free software: you can Use, Study, Modify and Redistribute # This program is free software: you can Use, Study, Modify and Redistribute
...@@ -121,13 +121,13 @@ def ext4subj(subj): ...@@ -121,13 +121,13 @@ def ext4subj(subj):
return ext return ext
# run_with_zodb3py2_compat(f) runs f preserving database compatibility with # run_with_zodb4py2_compat(f) runs f preserving database compatibility with
# ZODB3/py2, which cannot load pickles encoded with protocol 3. # ZODB4/py2, which generates pickles encoded with protocol < 3.
# #
# ZODB5 started to use protocol 3 and binary for oids starting from ZODB 5.4.0: # ZODB5 started to use protocol 3 and binary for oids starting from ZODB 5.4.0:
# https://github.com/zopefoundation/ZODB/commit/12ee41c4 # https://github.com/zopefoundation/ZODB/commit/12ee41c4
# Undo it, while we generate test database. # Undo it, while we generate test database.
def run_with_zodb3py2_compat(f): def run_with_zodb4py2_compat(f):
import ZODB.ConflictResolution import ZODB.ConflictResolution
import ZODB.Connection import ZODB.Connection
import ZODB.ExportImport import ZODB.ExportImport
...@@ -138,21 +138,21 @@ def run_with_zodb3py2_compat(f): ...@@ -138,21 +138,21 @@ def run_with_zodb3py2_compat(f):
import ZODB.serialize import ZODB.serialize
binary = getattr(ZODB.serialize, 'binary', None) binary = getattr(ZODB.serialize, 'binary', None)
_protocol = getattr(ZODB.serialize, '_protocol', None) _protocol = getattr(ZODB.serialize, '_protocol', None)
Pz3 = 2 Pz4 = 2
try: try:
ZODB.serialize.binary = bytes ZODB.serialize.binary = bytes
# XXX cannot change just ZODB._compat._protocol, because many modules # XXX cannot change just ZODB._compat._protocol, because many modules
# do `from ZODB._compat import _protocol` and just `import ZODB` # do `from ZODB._compat import _protocol` and just `import ZODB`
# imports many ZODB.X modules. In other words we cannot change # imports many ZODB.X modules. In other words we cannot change
# _protocol just in one place. # _protocol just in one place.
ZODB.ConflictResolution._protocol = Pz3 ZODB.ConflictResolution._protocol = Pz4
ZODB.Connection._protocol = Pz3 ZODB.Connection._protocol = Pz4
ZODB.ExportImport._protocol = Pz3 ZODB.ExportImport._protocol = Pz4
ZODB.FileStorage.FileStorage._protocol = Pz3 ZODB.FileStorage.FileStorage._protocol = Pz4
ZODB._compat._protocol = Pz3 ZODB._compat._protocol = Pz4
ZODB.broken._protocol = Pz3 ZODB.broken._protocol = Pz4
ZODB.fsIndex._protocol = Pz3 ZODB.fsIndex._protocol = Pz4
ZODB.serialize._protocol = Pz3 ZODB.serialize._protocol = Pz4
f() f()
finally: finally:
...@@ -172,7 +172,7 @@ def run_with_zodb3py2_compat(f): ...@@ -172,7 +172,7 @@ def run_with_zodb3py2_compat(f):
def gen_testdb(outfs_path, zext=True): def gen_testdb(outfs_path, zext=True):
def _(): def _():
_gen_testdb(outfs_path, zext) _gen_testdb(outfs_path, zext)
run_with_zodb3py2_compat(_) run_with_zodb4py2_compat(_)
def _gen_testdb(outfs_path, zext): def _gen_testdb(outfs_path, zext):
xtime_reset() xtime_reset()
......
...@@ -102,7 +102,7 @@ def zodbcommit(stor, at, txn): ...@@ -102,7 +102,7 @@ def zodbcommit(stor, at, txn):
stor.tpc_vote(txn) stor.tpc_vote(txn)
# in ZODB >= 5 tpc_finish returns tid directly, but on ZODB 4 and ZODB 3 it # in ZODB >= 5 tpc_finish returns tid directly, but on ZODB 4 it
# does not do so. Since we still need to support ZODB 4, utilize tpc_finish # does not do so. Since we still need to support ZODB 4, utilize tpc_finish
# callback to know with which tid the transaction was committed. # callback to know with which tid the transaction was committed.
_ = [] _ = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment