Skip to content

Commit 3cd2af5

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 0ce110a commit 3cd2af5

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.
@@ -69,6 +70,11 @@ class BibTexSchema(BaseSerializerSchema, CommonFieldsMixin):
6970
}
7071
"""Maps resource types to formats."""
7172

73+
def __init__(self, doi_all_versions=False, **kwargs):
74+
"""Construct."""
75+
super().__init__(**kwargs)
76+
self.doi_all_versions = doi_all_versions
77+
7278
@property
7379
def default_entry_type(self):
7480
"""Read-only property that defines the default bibtex entry type to be used.
@@ -79,7 +85,7 @@ def default_entry_type(self):
7985

8086
def get_id(self, obj):
8187
"""Get record id."""
82-
if self.context.get("doi_all_versions", False):
88+
if self.doi_all_versions:
8389
# If all versions export is requested, return the parent id
8490
return obj["parent"]["id"]
8591
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)