Commit fc0445c8 authored by Kirill Smelkov's avatar Kirill Smelkov

lib/zodb: zconn_at: Fix how ZODB4 is asserted to be patched

Fix how unpatched ZODB4 is reported to lack required patch:

Before:

    Traceback (most recent call last):
      File "/home/kirr/src/wendelin/wendelin.core/lib/tests/test_zodb.py", line 251, in test_zconn_at
        assert zconn_at(conn1) == at0
      File "/home/kirr/src/wendelin/wendelin.core/lib/zodb.py", line 162, in zconn_at
        assert 'conn:MVCC-via-loadBefore-only' in ZODB.nxd_patches, \
    AttributeError: 'module' object has no attribute 'nxd_patches'

After:

    Traceback (most recent call last):
      File "/home/kirr/src/wendelin/wendelin.core/lib/tests/test_zodb.py", line 251, in test_zconn_at
        assert zconn_at(conn1) == at0
      File "/home/kirr/src/wendelin/wendelin.core/lib/zodb.py", line 163, in zconn_at
        "ZODB!1")
      File "/home/kirr/src/wendelin/wendelin.core/lib/zodb.py", line 191, in _zassertHasNXDPatch
        (zmajor, patch, details_link))
    AssertionError: ZODB4 is not patched with required Nexedi patch 'conn:MVCC-via-loadBefore-only'
            See ZODB!1 for details

Fixes 1f866c00 (lib/zodb: Teach zconn_at to work on ZODB4).
parent fe9c46c9
......@@ -159,8 +159,8 @@ def zconn_at(zconn): # -> tid
# We rely on our patch in 4-nxd branch that reworks ZODB.Connection to
# implement MVCC via always calling loadBefore(zconn._txn_time) to load objects.
elif zmajor == 4:
assert 'conn:MVCC-via-loadBefore-only' in ZODB.nxd_patches, \
"https://lab.nexedi.com/nexedi/ZODB/merge_requests/1"
_zassertHasNXDPatch('conn:MVCC-via-loadBefore-only',
"https://lab.nexedi.com/nexedi/ZODB/merge_requests/1")
if zconn._mvcc_storage:
raise NotImplementedError("Connection.at for IMVCCStorage is not implemented")
......@@ -180,6 +180,14 @@ def before2at(before): # -> at
return p64(u64(before) - 1)
# _zassertHasNXDPatch asserts that ZODB is patched with specified Nexedi-provided patch.
def _zassertHasNXDPatch(patch, details_link):
nxd_patches = getattr(ZODB, 'nxd_patches', set())
if patch not in nxd_patches:
raise AssertionError(
"ZODB%s is not patched with required Nexedi patch %r\n\tSee %s for details" %
(zmajor, patch, details_link))
# _zversion returns ZODB version object
def _zversion():
dzodb3 = pkg_resources.working_set.find(pkg_resources.Requirement.parse('ZODB3'))
......
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