oarepo-runtime 1.4.3__py3-none-any.whl → 1.4.5__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,8 +53,9 @@ def load(
53
53
  def error_callback(entry: StreamEntry):
54
54
  pprint(entry.entry)
55
55
  for err in entry.errors:
56
- print(err.type)
56
+ print(err.code)
57
57
  print(err.message)
58
+ print(err.info)
58
59
 
59
60
  else:
60
61
  error_callback = None
@@ -0,0 +1,5 @@
1
+ class InvalidRelationError(KeyError):
2
+ def __init__(self, message, related_id, location):
3
+ self.related_id = related_id
4
+ self.location = location
5
+ super().__init__(message)
@@ -1,6 +1,7 @@
1
1
  from invenio_db import db
2
2
 
3
3
  from .base import Relation, RelationResult
4
+ from .errors import InvalidRelationError
4
5
  from .lookup import LookupResult
5
6
 
6
7
 
@@ -8,19 +9,23 @@ class PIDRelationResult(RelationResult):
8
9
  def resolve(self, id_):
9
10
  """Resolve the value using the record class."""
10
11
  # TODO: handle permissions here !!!!!!
11
- pid_field = self.field.pid_field.field
12
- cache_key = (
13
- pid_field._provider.pid_type
14
- if pid_field._provider
15
- else pid_field._pid_type,
16
- id_,
17
- )
12
+ pid_field_context = self.field.pid_field
13
+ if hasattr(pid_field_context, "pid_type"):
14
+ pid_type = pid_field_context.pid_type
15
+ else:
16
+ pid_field = pid_field_context.field
17
+ pid_type = (
18
+ pid_field._provider.pid_type
19
+ if pid_field._provider
20
+ else pid_field._pid_type
21
+ )
22
+ cache_key = (pid_type, id_)
18
23
  if cache_key in self.cache:
19
24
  obj = self.cache[cache_key]
20
25
  return obj
21
26
 
22
27
  try:
23
- obj = self.field.pid_field.resolve(id_)
28
+ obj = pid_field_context.resolve(id_)
24
29
  # We detach the related record model from the database session when
25
30
  # we add it in the cache. Otherwise, accessing the cached record
26
31
  # model, will execute a new select query after a db.session.commit.
@@ -28,8 +33,10 @@ class PIDRelationResult(RelationResult):
28
33
  self.cache[cache_key] = obj
29
34
  return obj
30
35
  except Exception as e:
31
- raise KeyError(
32
- f"Repository object {cache_key} has not been found or there was an exception accessing it"
36
+ raise InvalidRelationError(
37
+ f"Repository object {cache_key} has not been found or there was an exception accessing it. Referenced from {self.field.key}.",
38
+ related_id=id_,
39
+ location=self.field.key,
33
40
  ) from e
34
41
 
35
42
  def _needs_update_relation_value(self, relation: LookupResult):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.4.3
3
+ Version: 1.4.5
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -20,7 +20,7 @@ oarepo_runtime/config/service.py,sha256=IDDEQJ3LWYBLTFhE_8jPXiinIDNDY52fI0zigDJ_
20
20
  oarepo_runtime/datastreams/__init__.py,sha256=bscO2zTYf1eEppYx74b54-fcb2wz7YUDjGupqafuFc0,724
21
21
  oarepo_runtime/datastreams/batch.py,sha256=Xe0kXZigDeHU6Sjvo7w4_zjas8lShc2aTJpaAAQ3Iq0,551
22
22
  oarepo_runtime/datastreams/catalogue.py,sha256=TQjH7-qSrKhPEeq-7Q6OxmgGzvlsyrheVQbT_O4fwT8,5393
23
- oarepo_runtime/datastreams/cli.py,sha256=rats49mrlKwCAHPc-5795syRRghe6pJLsebSUPdO_-Y,2943
23
+ oarepo_runtime/datastreams/cli.py,sha256=heeXcbjqsC7HXK1HKNdkj25qISqdqXBsJQKFLpYhFDA,2975
24
24
  oarepo_runtime/datastreams/config.py,sha256=ALq7otBFMHjT3GV59KpkEV-8ZborWrYLXyB3v5-nFGE,1083
25
25
  oarepo_runtime/datastreams/datastreams.py,sha256=yzvyE8UzO3GUtaZOPHcIts8x0BPnLGIPjYH-JTCiU3g,8177
26
26
  oarepo_runtime/datastreams/errors.py,sha256=ZcwAsmczSTtHXljyDSrgqGhYD7td9rTLXZJvPjr72pA,1627
@@ -60,10 +60,11 @@ oarepo_runtime/i18n/validation.py,sha256=fyMTi2Rw-KiHv7c7HN61zGxRVa9sAjAEEkAL5wU
60
60
  oarepo_runtime/relations/__init__.py,sha256=bDAgxl_LdKsqpGG3qluxAkQnn5u2ItJngnHQKkqzlkE,373
61
61
  oarepo_runtime/relations/base.py,sha256=YLfZ_AKGv1uf-d22U01e7OwiBgW00lBmsPQbknhTFLI,8329
62
62
  oarepo_runtime/relations/components.py,sha256=J9rvzaAoRDbSVuA01hIOlXKQP-OE5VJI5w5xuMsFO70,602
63
+ oarepo_runtime/relations/errors.py,sha256=t-vVyefGPP07-_-YmhWjjGbhXU3GQ3sVtUPt5_IZ-5E,197
63
64
  oarepo_runtime/relations/internal.py,sha256=OTp8iJqyl80sWDk0Q0AK42l6UsxZDABspVU_GwWza9o,1556
64
65
  oarepo_runtime/relations/lookup.py,sha256=wi3jPfOedazOmhOMrgu50PUETc1jfSdpmjK0wvOFsEM,848
65
66
  oarepo_runtime/relations/mapping.py,sha256=jwFCWCnW8hb44ZZBeVf96QR79S9FT2hvm4L8EuCBo5U,1277
66
- oarepo_runtime/relations/pid_relation.py,sha256=OrF0Ihgua3tC7j5VBH116D5zHNHyodoeWux3ThLAZ3c,2063
67
+ oarepo_runtime/relations/pid_relation.py,sha256=SEAZ99x9lOj91EPSIDZuVCTWW1a13A5iv9RrO7GRdUY,2424
67
68
  oarepo_runtime/relations/uow.py,sha256=KrN8B-wVbmb0kOErxb7bAhPmOR6-mMRgBr-ab-ir6hQ,151
68
69
  oarepo_runtime/resolvers/__init__.py,sha256=kTlvSiympib59YQV7wEKpIXGprPWRuvxLIwmeeQdUec,89
69
70
  oarepo_runtime/resolvers/proxies.py,sha256=egtT7uXL91KswWI7gqUIaz1vWIHezdsiI_M-xRKXWww,547
@@ -80,9 +81,9 @@ oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,
80
81
  oarepo_runtime/validation/__init__.py,sha256=lU7DgZq8pGD5Pa-QqL9gvLsib3IYtM-Y56k-NwHrPG0,166
81
82
  oarepo_runtime/validation/dates.py,sha256=fahqKGDdIYWux5ZeoljrEe8VD2fDZR9VpfvYmTYAmpw,1050
82
83
  tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
- oarepo_runtime-1.4.3.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
84
- oarepo_runtime-1.4.3.dist-info/METADATA,sha256=thTpLDcWd4zYm0ehmc9YQ9Cy0SYdgklbvYn5jWWeG3s,2694
85
- oarepo_runtime-1.4.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
86
- oarepo_runtime-1.4.3.dist-info/entry_points.txt,sha256=C32W4eT-8OypMCfwOO5WREioVKSneDfY51D78Uvdbp0,231
87
- oarepo_runtime-1.4.3.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
88
- oarepo_runtime-1.4.3.dist-info/RECORD,,
84
+ oarepo_runtime-1.4.5.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
85
+ oarepo_runtime-1.4.5.dist-info/METADATA,sha256=bkQGyaHajVGMp4a54aM5O1zr0BuTnUSA33eTkC--G0s,2694
86
+ oarepo_runtime-1.4.5.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
87
+ oarepo_runtime-1.4.5.dist-info/entry_points.txt,sha256=C32W4eT-8OypMCfwOO5WREioVKSneDfY51D78Uvdbp0,231
88
+ oarepo_runtime-1.4.5.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
89
+ oarepo_runtime-1.4.5.dist-info/RECORD,,