oarepo-runtime 2.0.0.dev28__py3-none-any.whl → 2.0.0.dev30__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/api.py +30 -0
- oarepo_runtime/proxies.py +6 -2
- oarepo_runtime/resources/config.py +9 -1
- {oarepo_runtime-2.0.0.dev28.dist-info → oarepo_runtime-2.0.0.dev30.dist-info}/METADATA +1 -1
- {oarepo_runtime-2.0.0.dev28.dist-info → oarepo_runtime-2.0.0.dev30.dist-info}/RECORD +9 -9
- {oarepo_runtime-2.0.0.dev28.dist-info → oarepo_runtime-2.0.0.dev30.dist-info}/WHEEL +0 -0
- {oarepo_runtime-2.0.0.dev28.dist-info → oarepo_runtime-2.0.0.dev30.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-2.0.0.dev28.dist-info → oarepo_runtime-2.0.0.dev30.dist-info}/licenses/LICENSE +0 -0
oarepo_runtime/__init__.py
CHANGED
oarepo_runtime/api.py
CHANGED
@@ -24,6 +24,7 @@ if TYPE_CHECKING:
|
|
24
24
|
from collections.abc import Mapping
|
25
25
|
|
26
26
|
from flask_babel.speaklater import LazyString
|
27
|
+
from flask_resources.deserializers import DeserializerMixin
|
27
28
|
from flask_resources.responses import ResponseHandler
|
28
29
|
from flask_resources.serializers import BaseSerializer
|
29
30
|
from invenio_drafts_resources.records.api import Draft
|
@@ -92,6 +93,26 @@ class Export:
|
|
92
93
|
"""Description of the export format, human readable."""
|
93
94
|
|
94
95
|
|
96
|
+
@dataclasses.dataclass
|
97
|
+
class Import:
|
98
|
+
"""Configuration of an import format."""
|
99
|
+
|
100
|
+
code: str
|
101
|
+
"""Code of the import format, used to identify the import format in the URL."""
|
102
|
+
|
103
|
+
name: LazyString
|
104
|
+
"""Name of the import format, human readable."""
|
105
|
+
|
106
|
+
mimetype: str
|
107
|
+
"""MIME type of the import format."""
|
108
|
+
|
109
|
+
deserializer: DeserializerMixin
|
110
|
+
"""Deserializer used to deserialize the record into the import format."""
|
111
|
+
|
112
|
+
description: LazyString | None = None
|
113
|
+
"""Description of the import format, human readable."""
|
114
|
+
|
115
|
+
|
95
116
|
class Model[
|
96
117
|
S: RecordService = RecordService,
|
97
118
|
C: RecordServiceConfig = RecordServiceConfig,
|
@@ -131,6 +152,7 @@ class Model[
|
|
131
152
|
records_alias_enabled: bool = True,
|
132
153
|
model_metadata: ModelMetadata | None = None,
|
133
154
|
features: Mapping[str, Any] | None = None,
|
155
|
+
imports: list[Import] | None = None,
|
134
156
|
):
|
135
157
|
"""Initialize the model configuration.
|
136
158
|
|
@@ -155,6 +177,8 @@ class Model[
|
|
155
177
|
Such models will be searchable via the `/api/records` endpoint.
|
156
178
|
:param model_metadata: Metadata of the model.
|
157
179
|
:param features: Features of the model. Filled by the feature presets themselves during registration.
|
180
|
+
:param imports: List of import formats that can be used to import the record.
|
181
|
+
If not provided, no imports are available.
|
158
182
|
"""
|
159
183
|
self._code = code
|
160
184
|
self._name = name
|
@@ -176,6 +200,7 @@ class Model[
|
|
176
200
|
self._resource = resource
|
177
201
|
self._resource_config = resource_config
|
178
202
|
self._exports = exports or []
|
203
|
+
self._imports = imports or []
|
179
204
|
self._model_metadata = model_metadata
|
180
205
|
self._features = features
|
181
206
|
|
@@ -358,3 +383,8 @@ class Model[
|
|
358
383
|
def features(self) -> Mapping[str, Any] | None:
|
359
384
|
"""Get a mapping of features."""
|
360
385
|
return self._features
|
386
|
+
|
387
|
+
@property
|
388
|
+
def imports(self) -> list[Import]:
|
389
|
+
"""Get all importable request body parsers."""
|
390
|
+
return self._imports
|
oarepo_runtime/proxies.py
CHANGED
@@ -20,6 +20,10 @@ from werkzeug.local import LocalProxy
|
|
20
20
|
if TYPE_CHECKING:
|
21
21
|
from oarepo_runtime.ext import OARepoRuntime
|
22
22
|
|
23
|
-
current_runtime:
|
23
|
+
current_runtime: OARepoRuntime # type: ignore[reportRedeclaration]
|
24
24
|
|
25
|
-
|
25
|
+
# note: mypy does not understand LocalProxy[OARepoRuntime], so we type it as OARepoRuntime
|
26
|
+
# and ignore the redeclaration error
|
27
|
+
current_runtime = LocalProxy(lambda: current_app.extensions["oarepo-runtime"]) # type: ignore[assignment]
|
28
|
+
|
29
|
+
current_timezone: ContextVar = ContextVar("timezone")
|
@@ -13,13 +13,14 @@ from __future__ import annotations
|
|
13
13
|
|
14
14
|
from typing import TYPE_CHECKING
|
15
15
|
|
16
|
+
from flask_resources import RequestBodyParser
|
16
17
|
from flask_resources.responses import ResponseHandler
|
17
18
|
from invenio_records_resources.resources.records.headers import etag_headers
|
18
19
|
|
19
20
|
if TYPE_CHECKING:
|
20
21
|
from collections.abc import Iterable
|
21
22
|
|
22
|
-
from oarepo_runtime.api import Export
|
23
|
+
from oarepo_runtime.api import Export, Import
|
23
24
|
|
24
25
|
|
25
26
|
def exports_to_response_handlers(
|
@@ -33,3 +34,10 @@ def exports_to_response_handlers(
|
|
33
34
|
)
|
34
35
|
for export in exports
|
35
36
|
}
|
37
|
+
|
38
|
+
|
39
|
+
def imports_to_request_body_parsers(
|
40
|
+
imports: Iterable[Import],
|
41
|
+
) -> dict[str, RequestBodyParser]:
|
42
|
+
"""Convert imports to a dictionary of mimetype -> request body parsers."""
|
43
|
+
return {import_option.mimetype: RequestBodyParser(import_option.deserializer) for import_option in imports}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
oarepo_runtime/__init__.py,sha256=
|
2
|
-
oarepo_runtime/api.py,sha256=
|
1
|
+
oarepo_runtime/__init__.py,sha256=ETP5uM63MsDXj1RW_UvU0-87uGZCq3M0LRJKBevovYQ,686
|
2
|
+
oarepo_runtime/api.py,sha256=tLPgKv1iao2ZeL0tTJeA85019_sMW_dQAleayOeXjgI,14200
|
3
3
|
oarepo_runtime/config.py,sha256=RUEPFn_5bKp9Wb0OY-Fb3VK30m35vF5IsLjYaQHhP3g,3838
|
4
4
|
oarepo_runtime/ext.py,sha256=NgiRNl_hwTvEWcXnNwVh_XCPJyvwr3dZkdPmkWvN1xo,8785
|
5
|
-
oarepo_runtime/proxies.py,sha256=
|
5
|
+
oarepo_runtime/proxies.py,sha256=x8Y1iTP8QIzSI67s90VR0_5fvXuT1xlJXtAHsaoXFwg,903
|
6
6
|
oarepo_runtime/py.typed,sha256=RznSCjXReEUI9zkmD25E8XniG_MvPpLBF6MyNZA8MmE,42
|
7
7
|
oarepo_runtime/typing.py,sha256=vH8UUb4QTJowuvibwHaOOEwxx8i21LcOeplxJl0Yrew,1594
|
8
8
|
oarepo_runtime/cli/__init__.py,sha256=H7GOeOBf0udgKWOdlAQswIMvRrD8BwcEjOVxIqP0Suw,731
|
@@ -19,7 +19,7 @@ oarepo_runtime/records/systemfields/mapping.py,sha256=HC9QnY6J6Ftw-DwotKUTvnyRif
|
|
19
19
|
oarepo_runtime/records/systemfields/publication_status.py,sha256=1g3VXNPh0FsiPCpe-7ZuaMEF4x8ffrDrt37Rqnjp0ng,2027
|
20
20
|
oarepo_runtime/records/systemfields/selectors.py,sha256=ijVDwAXaXTV5NtcXsrALkhddgCogLNe2eEscFr23qyg,1656
|
21
21
|
oarepo_runtime/resources/__init__.py,sha256=voynQULXoOEviADkbOpekMphZPTAz4IOTg5BF9xPwTM,453
|
22
|
-
oarepo_runtime/resources/config.py,sha256=
|
22
|
+
oarepo_runtime/resources/config.py,sha256=Lbx1QPWAJ8z1truhYntbnhGGWp2OCcwqKm6BuvPJNT0,1330
|
23
23
|
oarepo_runtime/services/__init__.py,sha256=OGtBgEeaDTyk2RPDNXuKbU9_7egFBZr42SM0gN5FrF4,341
|
24
24
|
oarepo_runtime/services/generators.py,sha256=8Z2QGzob4c2vaaNqhcMZsRybmwtOt30Plgf3EFmcJXw,4622
|
25
25
|
oarepo_runtime/services/results.py,sha256=qzoIQW5-ShL1YJDgPjfTlPnsgfEZhojNehhHNTUxRgI,7120
|
@@ -41,8 +41,8 @@ oarepo_runtime/services/schema/__init__.py,sha256=jgAPI_uKC6Ug4KQWnwQVg3-aNaw-eH
|
|
41
41
|
oarepo_runtime/services/schema/i18n.py,sha256=9D1zOQaPKAnYzejB0vO-m2BJYnam0N0Lrq4jID7twfE,3174
|
42
42
|
oarepo_runtime/services/schema/i18n_ui.py,sha256=DbusphhGDeaobTt4nuwNgKZ6Houlu4Sv3SuMGkdjRRY,3582
|
43
43
|
oarepo_runtime/services/schema/ui.py,sha256=6HPRMOytE7UQnGd4Z21kvYTpX5p_g2TmP2_v4pwkU8w,4524
|
44
|
-
oarepo_runtime-2.0.0.
|
45
|
-
oarepo_runtime-2.0.0.
|
46
|
-
oarepo_runtime-2.0.0.
|
47
|
-
oarepo_runtime-2.0.0.
|
48
|
-
oarepo_runtime-2.0.0.
|
44
|
+
oarepo_runtime-2.0.0.dev30.dist-info/METADATA,sha256=yyR8GUfH0IbW4L0KQDM0f7QRN7QH2iu43R8JcgXiAko,4723
|
45
|
+
oarepo_runtime-2.0.0.dev30.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
46
|
+
oarepo_runtime-2.0.0.dev30.dist-info/entry_points.txt,sha256=rOfs8R1oXFN_dLH9zAZ6ydkvr83mDajegc6NBIRsCMQ,318
|
47
|
+
oarepo_runtime-2.0.0.dev30.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
48
|
+
oarepo_runtime-2.0.0.dev30.dist-info/RECORD,,
|
File without changes
|
{oarepo_runtime-2.0.0.dev28.dist-info → oarepo_runtime-2.0.0.dev30.dist-info}/entry_points.txt
RENAMED
File without changes
|
{oarepo_runtime-2.0.0.dev28.dist-info → oarepo_runtime-2.0.0.dev30.dist-info}/licenses/LICENSE
RENAMED
File without changes
|