oarepo-runtime 1.5.44__py3-none-any.whl → 1.5.46__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.
@@ -15,7 +15,8 @@ def get_record_service_for_record(record):
15
15
  if not record:
16
16
  return None
17
17
  if "OAREPO_PRIMARY_RECORD_SERVICE" in current_app.config:
18
- return current_app.config["OAREPO_PRIMARY_RECORD_SERVICE"][type(record)]
18
+ service_id = current_app.config["OAREPO_PRIMARY_RECORD_SERVICE"][type(record)]
19
+ return current_service_registry.get(service_id)
19
20
  else:
20
21
  return get_record_service_for_record_deprecated(record)
21
22
 
@@ -1,4 +1,4 @@
1
- from typing import List, Any
1
+ from typing import Any, List
2
2
 
3
3
 
4
4
  class Selector:
@@ -70,7 +70,9 @@ class SyntheticSystemField(MappingSystemFieldMixin, SystemField):
70
70
  ```
71
71
  """
72
72
 
73
- def __init__(self, selector: Selector=None, filter=None, map=None, key=None, **kwargs):
73
+ def __init__(
74
+ self, selector: Selector = None, filter=None, map=None, key=None, **kwargs
75
+ ):
74
76
  self.selector = selector
75
77
  self.map = map
76
78
  self.filter = filter
@@ -4,11 +4,10 @@ from .permissions_presets import (
4
4
  OaiHarvesterPermissionPolicy,
5
5
  ReadOnlyPermissionPolicy,
6
6
  )
7
- from .service import PermissionsPresetsConfigMixin, UserWithRole
7
+ from .service import PermissionsPresetsConfigMixin
8
8
 
9
9
  __all__ = (
10
10
  "PermissionsPresetsConfigMixin",
11
- "UserWithRole",
12
11
  "OaiHarvesterPermissionPolicy",
13
12
  "ReadOnlyPermissionPolicy",
14
13
  "EveryonePermissionPolicy",
@@ -3,10 +3,7 @@ import re
3
3
  from typing import List, Type
4
4
 
5
5
  from flask import current_app
6
- from flask_principal import RoleNeed
7
6
  from invenio_records_permissions import BasePermissionPolicy
8
- from invenio_records_permissions.generators import Generator
9
- from invenio_search.engine import dsl
10
7
 
11
8
  from oarepo_runtime.utils.functools import class_property
12
9
 
@@ -103,19 +100,3 @@ class PermissionsPresetsConfigMixin:
103
100
  name = name[:-6]
104
101
  name = re.sub(r"(?<!^)(?=[A-Z])", "_", name).upper()
105
102
  return f"{name}_PERMISSIONS_PRESETS"
106
-
107
-
108
- class UserWithRole(Generator):
109
- def __init__(self, *roles):
110
- self.roles = roles
111
-
112
- def needs(self, **kwargs):
113
- return [RoleNeed(role) for role in self.roles]
114
-
115
- def query_filter(self, identity=None, **kwargs):
116
- if not identity:
117
- return dsl.Q("match_none")
118
- for provide in identity.provides:
119
- if provide.method == "role" and provide.value in self.roles:
120
- return dsl.Q("match_all")
121
- return dsl.Q("match_none")
@@ -1,24 +1,10 @@
1
- from flask_principal import UserNeed
2
- from invenio_records_permissions.generators import Generator
3
- from invenio_search.engine import dsl
1
+ import warnings
4
2
 
3
+ from .permissions import RecordOwners
5
4
 
6
- class RecordOwners(Generator):
7
- """Allows record owners."""
8
-
9
- def needs(self, record=None, **kwargs):
10
- """Enabling Needs."""
11
- if record is None:
12
- # 'record' is required, so if not passed we default to empty array,
13
- # i.e. superuser-access.
14
- return []
15
- owners = getattr(record.parent, "owners", None)
16
- if owners is not None:
17
- return [UserNeed(owner.id) for owner in owners]
18
- return []
19
-
20
- def query_filter(self, identity=None, **kwargs):
21
- """Filters for current identity as owner."""
22
- users = [n.value for n in identity.provides if n.method == "id"]
23
- if users:
24
- return dsl.Q("terms", **{"parent.owners.user": users})
5
+ warnings.warn(
6
+ "oarepo_runtime.services.generators is deprecated, import RecordOwners from "
7
+ "oarepo_runtime.services.permissions",
8
+ DeprecationWarning,
9
+ )
10
+ __all__ = ("RecordOwners",)
@@ -0,0 +1,3 @@
1
+ from .generators import RecordOwners, UserWithRole
2
+
3
+ __all__ = ("RecordOwners", "UserWithRole")
@@ -0,0 +1,40 @@
1
+ from flask_principal import RoleNeed, UserNeed
2
+ from invenio_records_permissions.generators import Generator
3
+ from invenio_search.engine import dsl
4
+
5
+
6
+ class RecordOwners(Generator):
7
+ """Allows record owners."""
8
+
9
+ def needs(self, record=None, **kwargs):
10
+ """Enabling Needs."""
11
+ if record is None:
12
+ # 'record' is required, so if not passed we default to empty array,
13
+ # i.e. superuser-access.
14
+ return []
15
+ owners = getattr(record.parent, "owners", None)
16
+ if owners is not None:
17
+ return [UserNeed(owner.id) for owner in owners]
18
+ return []
19
+
20
+ def query_filter(self, identity=None, **kwargs):
21
+ """Filters for current identity as owner."""
22
+ users = [n.value for n in identity.provides if n.method == "id"]
23
+ if users:
24
+ return dsl.Q("terms", **{"parent.owners.user": users})
25
+
26
+
27
+ class UserWithRole(Generator):
28
+ def __init__(self, *roles):
29
+ self.roles = roles
30
+
31
+ def needs(self, **kwargs):
32
+ return [RoleNeed(role) for role in self.roles]
33
+
34
+ def query_filter(self, identity=None, **kwargs):
35
+ if not identity:
36
+ return dsl.Q("match_none")
37
+ for provide in identity.provides:
38
+ if provide.method == "role" and provide.value in self.roles:
39
+ return dsl.Q("match_all")
40
+ return dsl.Q("match_none")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.44
3
+ Version: 1.5.46
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -25,7 +25,7 @@ oarepo_runtime/datastreams/semi_asynchronous.py,sha256=TJWby2MDKXm5feRocoWB-8Ohs
25
25
  oarepo_runtime/datastreams/synchronous.py,sha256=t5lfnMkLqy3jK5zMl-nIuA0HlMPiHGjwCqZ8XQP-3GM,2595
26
26
  oarepo_runtime/datastreams/transformers.py,sha256=q5KzHPl2kJg7HP1BtKJ7F_UMqg_7L1ZGDX0O7s8D6UI,521
27
27
  oarepo_runtime/datastreams/types.py,sha256=KZjblc3T_UFFW7LrMDmiR8lqVf86V484LAHj6yg05EI,9908
28
- oarepo_runtime/datastreams/utils.py,sha256=PAUVyL6AuD20PtESJcUEXsUeeSnxxKUB9LzxqwAgx9U,3939
28
+ oarepo_runtime/datastreams/utils.py,sha256=GYpVdwMks0GRdz8DBpErdiV_2aJ-3V1uAkOHyz67bZw,4001
29
29
  oarepo_runtime/datastreams/readers/__init__.py,sha256=P1n3llZQ3AFHnSPbeT1VaCJcEtRFz9AbHfjkZv5LG7s,1103
30
30
  oarepo_runtime/datastreams/readers/attachments.py,sha256=A7EC1TqyTHG-go5DIaRotlBSOm6o9hGqAKyVVAceCRU,1956
31
31
  oarepo_runtime/datastreams/readers/excel.py,sha256=CM8lr8mejN7NgoK5TJb1oXpjq0HxklQKMsuj3uqjTjA,3653
@@ -62,19 +62,19 @@ oarepo_runtime/records/systemfields/icu.py,sha256=sSGAgi5WhsAY4cCBL7-7nMpvHAuctp
62
62
  oarepo_runtime/records/systemfields/mapping.py,sha256=tXOK_jkdY1pOUO7_VfChfDNB8UTi21GUXaidpugTnO8,1017
63
63
  oarepo_runtime/records/systemfields/owner.py,sha256=dYRVBinniW7ECHuSnTAjeN6x1KhhJtNR9vxmD1KswMs,3805
64
64
  oarepo_runtime/records/systemfields/record_status.py,sha256=U3kem4-JkNsT17e0iAl3HIAZ2MvO5lY_0U757aZvTKE,935
65
- oarepo_runtime/records/systemfields/selectors.py,sha256=8e8LaepwU5hrft8UDDJ1_FkxeZxBW0-JJKgUnqWHOx4,928
66
- oarepo_runtime/records/systemfields/synthetic.py,sha256=6Le2lHMIPXY2JKW31ymPlYRZtIRriyxDp2xKPFbTK3o,4271
65
+ oarepo_runtime/records/systemfields/selectors.py,sha256=rXNioeyCHLiNGsA_zu8bfoFdu29ACSNN7zHRUm1rJ6Q,928
66
+ oarepo_runtime/records/systemfields/synthetic.py,sha256=UustvhzcDGuaNZLDeHbWwshoxQR-qRIuHDCct5RXmrI,4287
67
67
  oarepo_runtime/resources/__init__.py,sha256=v8BGrOTu_FjKzd0eozV7Q4GoGxyfybsL2cI-tbP5Pys,185
68
68
  oarepo_runtime/resources/file_resource.py,sha256=Ta3bFce7l0xwqkkOMOEu9mxbB8BbKj5HUHRHmidhnl8,414
69
69
  oarepo_runtime/resources/localized_ui_json_serializer.py,sha256=3V9cJaG_e1PMXKVX_wKfBp1LmbeForwHyBNYdyha4uQ,1878
70
70
  oarepo_runtime/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
71
  oarepo_runtime/services/components.py,sha256=FkqyFe6-5HZKJDqglQ-Smm_AIsDZ-LyWcOr1u2yGu3k,1836
72
- oarepo_runtime/services/generators.py,sha256=V582uA813AIXnFhzqUwakmDgBOI1SQe3XZeJtUXNbwM,872
72
+ oarepo_runtime/services/generators.py,sha256=j87HitHA_w2awsz0C5IAAJ0qjg9JMtvdO3dvh6FQyfg,250
73
73
  oarepo_runtime/services/results.py,sha256=gPmQ7DzX4da5zuvqQE7u-AUn_Yvz-YHt8W8DaxPbQ-M,2706
74
74
  oarepo_runtime/services/search.py,sha256=9xGTN5Yg6eTdptQ9qjO_umbacf9ooMuHYGXWYfla4-M,6227
75
- oarepo_runtime/services/config/__init__.py,sha256=SCqww5sV8qh3gmev6TE8EyJbD58juIEDCm_7MEHxtSg,440
75
+ oarepo_runtime/services/config/__init__.py,sha256=dtlD84pJ6xI77UF22IPrCOt7tHD3g5DAEDApUdjDVFE,406
76
76
  oarepo_runtime/services/config/permissions_presets.py,sha256=zApeA-2DYAlD--SzVz3vq_OFjq48Ko0pe08e4o2vxr4,6114
77
- oarepo_runtime/services/config/service.py,sha256=CJNBbFJmXEdEpLGrefQSGJVGRcJAtf-619Xdm1iK5_A,4627
77
+ oarepo_runtime/services/config/service.py,sha256=s-dVbGkLICpsce6jgu7b5kzYFz9opWjSQFDBgbIhKio,4002
78
78
  oarepo_runtime/services/custom_fields/__init__.py,sha256=xJ7XEyMJHPfIgX5JKpgpwh7SYc9Zee2dC5oC8cm99Qc,2282
79
79
  oarepo_runtime/services/custom_fields/mappings.py,sha256=tg9CAdxGOkd_n6RB5Z2_wSwo_A0wqEey8RMcZ79AHo0,6906
80
80
  oarepo_runtime/services/expansions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -92,6 +92,8 @@ oarepo_runtime/services/facets/year_histogram.py,sha256=kdfwx1lgw4UmfjdaqqeElJCB
92
92
  oarepo_runtime/services/files/__init__.py,sha256=K8MStrEQf_BUhvzhwPTF93Hkhwrd1dtv35LDo7iZeTM,268
93
93
  oarepo_runtime/services/files/components.py,sha256=x6Wd-vvkqTqB1phj2a6h42DNQksN8PuR2XKaOGoNHfw,2400
94
94
  oarepo_runtime/services/files/service.py,sha256=8DH0Pefr9kilM2JnOb-UYsnqerE8Z1Mu4p6DOJ4j_ZU,608
95
+ oarepo_runtime/services/permissions/__init__.py,sha256=Cgin2Zr1fpaYr-aZcUotdmv0hsrPTUJVQt8ouvU8tuU,95
96
+ oarepo_runtime/services/permissions/generators.py,sha256=YEOBCCvU-RG0BSWMtg76sv8qLcMbXxNu3rRJPDLtvvQ,1371
95
97
  oarepo_runtime/services/relations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
98
  oarepo_runtime/services/relations/components.py,sha256=3g0VdnGUM-2yYt50fPi-OADReBGJb4h05vmYHfh-QFs,592
97
99
  oarepo_runtime/services/relations/errors.py,sha256=VtlOKq9MEUeJ4IsiZhY7lWoshrusA_RL4SOHe2titno,552
@@ -117,9 +119,9 @@ oarepo_runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
117
119
  oarepo_runtime/utils/functools.py,sha256=gKS9YZtlIYcDvdNA9cmYO00yjiXBYV1jg8VpcRUyQyg,1324
118
120
  oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,3108
119
121
  tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
120
- oarepo_runtime-1.5.44.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
121
- oarepo_runtime-1.5.44.dist-info/METADATA,sha256=pDJg1hNUd-gXeg2V2bhwmr0aIofecKPJb_43bXQF4RQ,4680
122
- oarepo_runtime-1.5.44.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
123
- oarepo_runtime-1.5.44.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
124
- oarepo_runtime-1.5.44.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
125
- oarepo_runtime-1.5.44.dist-info/RECORD,,
122
+ oarepo_runtime-1.5.46.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
123
+ oarepo_runtime-1.5.46.dist-info/METADATA,sha256=qSraV8TexG2hMsNg1VcQW77Px24z_3A5njdIodRPp30,4680
124
+ oarepo_runtime-1.5.46.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
125
+ oarepo_runtime-1.5.46.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
126
+ oarepo_runtime-1.5.46.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
127
+ oarepo_runtime-1.5.46.dist-info/RECORD,,