Skip to content

Commit 8e761b5

Browse files
committed
fix(chore): RemovedInMarshmallow4Warning
* The `context` parameter is deprecated and will be removed in marshmallow 4.0. Use `contextvars.ContextVar` to pass context instead. * doi_all_versions moved to schema_kwargs which will be injected into the schema as property
1 parent beff65f commit 8e761b5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

invenio_rdm_records/resources/serializers/bibtex/schema.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
#
33
# Copyright (C) 2023-2025 CERN
4+
# Copyright (C) 2025 Graz University of Technology.
45
#
56
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
67
# it under the terms of the MIT License; see LICENSE file for more details.
@@ -71,6 +72,11 @@ class BibTexSchema(BaseSerializerSchema, CommonFieldsMixin):
7172
}
7273
"""Maps resource types to formats."""
7374

75+
def __init__(self, doi_all_versions=False, **kwargs):
76+
"""Construct."""
77+
super().__init__(**kwargs)
78+
self.doi_all_versions = doi_all_versions
79+
7480
@property
7581
def default_entry_type(self):
7682
"""Read-only property that defines the default bibtex entry type to be used.
@@ -81,7 +87,7 @@ def default_entry_type(self):
8187

8288
def get_id(self, obj):
8389
"""Get record id."""
84-
if self.context.get("doi_all_versions", False):
90+
if self.doi_all_versions:
8591
# If all versions export is requested, return the parent id
8692
return obj["parent"]["id"]
8793
return obj["id"]

tests/resources/serializers/test_bibtex_serializer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
#
33
# Copyright (C) 2023-2025 CERN
4+
# Copyright (C) 2025 Graz University of Technology.
45
#
56
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
67
# it under the terms of the MIT License; see LICENSE file for more details.
@@ -85,7 +86,7 @@ def test_bibtex_serializer_full_record(running_app, updated_full_record):
8586

8687
def test_bibtex_serializer_record_all_versions(running_app, updated_full_record):
8788
"""Test serializer for BibTex (All versions)."""
88-
serializer = BibtexSerializer(schema_context={"doi_all_versions": True})
89+
serializer = BibtexSerializer(schema_kargs={"doi_all_versions": True})
8990
serialized_record = serializer.serialize_object(updated_full_record)
9091

9192
expected_data = (

0 commit comments

Comments
 (0)