oarepo-runtime 2.0.0.dev15__py3-none-any.whl → 2.0.0.dev16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oarepo_runtime/__init__.py +1 -1
- oarepo_runtime/ext.py +11 -0
- {oarepo_runtime-2.0.0.dev15.dist-info → oarepo_runtime-2.0.0.dev16.dist-info}/METADATA +1 -1
- {oarepo_runtime-2.0.0.dev15.dist-info → oarepo_runtime-2.0.0.dev16.dist-info}/RECORD +7 -7
- {oarepo_runtime-2.0.0.dev15.dist-info → oarepo_runtime-2.0.0.dev16.dist-info}/WHEEL +0 -0
- {oarepo_runtime-2.0.0.dev15.dist-info → oarepo_runtime-2.0.0.dev16.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-2.0.0.dev15.dist-info → oarepo_runtime-2.0.0.dev16.dist-info}/licenses/LICENSE +0 -0
oarepo_runtime/__init__.py
CHANGED
oarepo_runtime/ext.py
CHANGED
@@ -29,6 +29,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
29
29
|
from flask import Flask
|
30
30
|
from invenio_drafts_resources.records.api import Draft
|
31
31
|
from invenio_records_resources.services.base.service import Service
|
32
|
+
from invenio_records_resources.services.files.service import FileService
|
32
33
|
from invenio_records_resources.services.records import RecordService
|
33
34
|
|
34
35
|
from .api import Model
|
@@ -170,6 +171,16 @@ class OARepoRuntime:
|
|
170
171
|
raise ValueError("Need to pass a record instance, got None")
|
171
172
|
return self.get_record_service_for_record_class(type(record))
|
172
173
|
|
174
|
+
def get_file_service_for_record(self, record: Any) -> FileService | None:
|
175
|
+
"""Return the file service for the given record (draft or published)."""
|
176
|
+
model = self.models_by_record_class.get(type(record))
|
177
|
+
if not model:
|
178
|
+
raise KeyError(f"No model found for record class '{type(record).__name__}'.")
|
179
|
+
is_draft = getattr(record, "is_draft", False)
|
180
|
+
if is_draft:
|
181
|
+
return model.draft_file_service
|
182
|
+
return model.file_service
|
183
|
+
|
173
184
|
def get_record_service_for_record_class(self, record_cls: type[RecordBase]) -> RecordService:
|
174
185
|
"""Retrieve the service associated with a given record class."""
|
175
186
|
for t in record_cls.mro():
|
@@ -1,7 +1,7 @@
|
|
1
|
-
oarepo_runtime/__init__.py,sha256=
|
1
|
+
oarepo_runtime/__init__.py,sha256=EYMIFqYilaHmxa2EXZEYbZsoBTsdit088W4sOV_VlrY,686
|
2
2
|
oarepo_runtime/api.py,sha256=7gPeRS66moT1lIedPRmuK0EnB8PpGO7iD5eRCQOty4U,12552
|
3
3
|
oarepo_runtime/config.py,sha256=RUEPFn_5bKp9Wb0OY-Fb3VK30m35vF5IsLjYaQHhP3g,3838
|
4
|
-
oarepo_runtime/ext.py,sha256=
|
4
|
+
oarepo_runtime/ext.py,sha256=G9j5IgnVPdE656qaiN4RllpOkdyToP8v9uwas3DdpTY,8451
|
5
5
|
oarepo_runtime/proxies.py,sha256=PXaRiBh5qs5-h8M81cJOgtqypFQcYUSjiSn2TLSujRw,648
|
6
6
|
oarepo_runtime/py.typed,sha256=RznSCjXReEUI9zkmD25E8XniG_MvPpLBF6MyNZA8MmE,42
|
7
7
|
oarepo_runtime/cli/__init__.py,sha256=H7GOeOBf0udgKWOdlAQswIMvRrD8BwcEjOVxIqP0Suw,731
|
@@ -30,8 +30,8 @@ oarepo_runtime/services/records/mapping.py,sha256=y3oeToKEnaRYpMV3q2-2cXNzyzyL3X
|
|
30
30
|
oarepo_runtime/services/schema/__init__.py,sha256=jgAPI_uKC6Ug4KQWnwQVg3-aNaw-eHja323AUFo5ELo,351
|
31
31
|
oarepo_runtime/services/schema/i18n.py,sha256=9D1zOQaPKAnYzejB0vO-m2BJYnam0N0Lrq4jID7twfE,3174
|
32
32
|
oarepo_runtime/services/schema/i18n_ui.py,sha256=DbusphhGDeaobTt4nuwNgKZ6Houlu4Sv3SuMGkdjRRY,3582
|
33
|
-
oarepo_runtime-2.0.0.
|
34
|
-
oarepo_runtime-2.0.0.
|
35
|
-
oarepo_runtime-2.0.0.
|
36
|
-
oarepo_runtime-2.0.0.
|
37
|
-
oarepo_runtime-2.0.0.
|
33
|
+
oarepo_runtime-2.0.0.dev16.dist-info/METADATA,sha256=FW8t5tWe50gjPnvnTiK9MOkERwCstTehTor07Bh5r5g,4495
|
34
|
+
oarepo_runtime-2.0.0.dev16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
35
|
+
oarepo_runtime-2.0.0.dev16.dist-info/entry_points.txt,sha256=rOfs8R1oXFN_dLH9zAZ6ydkvr83mDajegc6NBIRsCMQ,318
|
36
|
+
oarepo_runtime-2.0.0.dev16.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
37
|
+
oarepo_runtime-2.0.0.dev16.dist-info/RECORD,,
|
File without changes
|
{oarepo_runtime-2.0.0.dev15.dist-info → oarepo_runtime-2.0.0.dev16.dist-info}/entry_points.txt
RENAMED
File without changes
|
{oarepo_runtime-2.0.0.dev15.dist-info → oarepo_runtime-2.0.0.dev16.dist-info}/licenses/LICENSE
RENAMED
File without changes
|