oarepo-runtime 1.2.20__tar.gz → 1.2.21__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. {oarepo-runtime-1.2.20/oarepo_runtime.egg-info → oarepo-runtime-1.2.21}/PKG-INFO +1 -1
  2. oarepo-runtime-1.2.21/oarepo_runtime/relations/components.py +15 -0
  3. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/mapping.py +10 -0
  4. oarepo-runtime-1.2.21/oarepo_runtime/relations/uow.py +7 -0
  5. oarepo-runtime-1.2.21/oarepo_runtime/validation/__init__.py +3 -0
  6. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/validation/dates.py +16 -2
  7. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21/oarepo_runtime.egg-info}/PKG-INFO +1 -1
  8. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/SOURCES.txt +2 -0
  9. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/setup.cfg +1 -1
  10. oarepo-runtime-1.2.20/oarepo_runtime/validation/__init__.py +0 -3
  11. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/LICENSE +0 -0
  12. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/MANIFEST.in +0 -0
  13. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/README.md +0 -0
  14. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/__init__.py +0 -0
  15. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/cf/__init__.py +0 -0
  16. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/cf/cli.py +0 -0
  17. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/cf/mappings.py +0 -0
  18. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/cli/__init__.py +0 -0
  19. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/cli/base.py +0 -0
  20. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/cli/index.py +0 -0
  21. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/config/__init__.py +0 -0
  22. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/config/permissions_presets.py +0 -0
  23. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/config/service.py +0 -0
  24. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/__init__.py +0 -0
  25. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/batch.py +0 -0
  26. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/catalogue.py +0 -0
  27. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/cli.py +0 -0
  28. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/config.py +0 -0
  29. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/datastreams.py +0 -0
  30. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/errors.py +0 -0
  31. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/fixtures.py +0 -0
  32. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/__init__.py +0 -0
  33. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/excel.py +0 -0
  34. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/json.py +0 -0
  35. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/service.py +0 -0
  36. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/yaml.py +0 -0
  37. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/transformers.py +0 -0
  38. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/writers/__init__.py +0 -0
  39. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/writers/service.py +0 -0
  40. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/writers/yaml.py +0 -0
  41. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/expansions/__init__.py +0 -0
  42. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/expansions/expandable_fields.py +0 -0
  43. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/expansions/service.py +0 -0
  44. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/ext.py +0 -0
  45. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/ext_config.py +0 -0
  46. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/__init__.py +0 -0
  47. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/base.py +0 -0
  48. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/date.py +0 -0
  49. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/enum.py +0 -0
  50. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/max_facet.py +0 -0
  51. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/nested_facet.py +0 -0
  52. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/i18n/__init__.py +0 -0
  53. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/i18n/schema.py +0 -0
  54. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/i18n/ui_schema.py +0 -0
  55. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/i18n/validation.py +0 -0
  56. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/__init__.py +0 -0
  57. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/base.py +0 -0
  58. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/internal.py +0 -0
  59. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/lookup.py +0 -0
  60. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/pid_relation.py +0 -0
  61. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/tasks/__init__.py +0 -0
  62. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/tasks/datastreams.py +0 -0
  63. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/ui/__init__.py +0 -0
  64. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime/ui/marshmallow.py +0 -0
  65. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/dependency_links.txt +0 -0
  66. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/entry_points.txt +0 -0
  67. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/requires.txt +0 -0
  68. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/top_level.txt +0 -0
  69. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/pyproject.toml +0 -0
  70. {oarepo-runtime-1.2.20 → oarepo-runtime-1.2.21}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.2.20
3
+ Version: 1.2.21
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  Provides-Extra: devs
@@ -0,0 +1,15 @@
1
+ from invenio_records_resources.services.records.components import ServiceComponent
2
+
3
+ from oarepo_runtime.relations import PIDRelation
4
+ from oarepo_runtime.relations.uow import CachingUnitOfWork
5
+
6
+
7
+ class CachingRelationsComponent(ServiceComponent):
8
+ def create(self, identity, *, record, **kwargs):
9
+ """Create handler."""
10
+ # skutecny jmeno relations atributu
11
+ if isinstance(self.uow, CachingUnitOfWork) and hasattr(record, "relations"):
12
+ record.relations.set_cache(self.uow.cache)
13
+ def update(self, identity, *, record, **kwargs):
14
+ """Update handler."""
15
+ self.create(identity, record=record, **kwargs)
@@ -1,3 +1,6 @@
1
+
2
+
3
+
1
4
  class RelationsMapping:
2
5
  """Helper class for managing relation fields."""
3
6
 
@@ -28,3 +31,10 @@ class RelationsMapping:
28
31
  """Clean dereferenced relation fields."""
29
32
  for name in fields or self:
30
33
  getattr(self, name).clean()
34
+
35
+ def set_cache(self, cache):
36
+ from oarepo_runtime.relations import PIDRelation
37
+ for key, fld in self._fields.items():
38
+ if isinstance(fld, PIDRelation):
39
+ fld.cache = cache
40
+ getattr(self, key).cache = cache
@@ -0,0 +1,7 @@
1
+ from invenio_records_resources.services.uow import UnitOfWork
2
+
3
+
4
+ class CachingUnitOfWork(UnitOfWork):
5
+ def __init__(self, *args, **kwargs):
6
+ super().__init__(*args, **kwargs)
7
+ self.cache = {}
@@ -0,0 +1,3 @@
1
+ from .dates import validate_date, validate_datetime, CachedMultilayerEDTFValidator
2
+
3
+ __all__ = ["validate_date", "validate_datetime", "CachedMultilayerEDTFValidator"]
@@ -1,6 +1,8 @@
1
+ import functools
2
+ import re
1
3
  from datetime import datetime
2
-
3
4
  from marshmallow.exceptions import ValidationError
5
+ from marshmallow_utils.fields.edtfdatestring import EDTFValidator
4
6
 
5
7
 
6
8
  def validate_date(date_format):
@@ -14,7 +16,6 @@ def validate_date(date_format):
14
16
 
15
17
  return validate
16
18
 
17
-
18
19
  def validate_datetime(value):
19
20
  try:
20
21
  datetime.fromisoformat(value)
@@ -22,3 +23,16 @@ def validate_datetime(value):
22
23
  raise ValidationError(
23
24
  f"Invalid datetime format, expecting iso format, got {value}"
24
25
  ) from e
26
+
27
+ class CachedMultilayerEDTFValidator(EDTFValidator):
28
+
29
+ @functools.lru_cache(maxsize=1024)
30
+ def __call__(self, value):
31
+ if re.match(r"^\d{4}$", value):
32
+ return value
33
+ try:
34
+ datetime.strptime(value, "%Y-%m-%d")
35
+ return value
36
+ except:
37
+ return super().__call__(value)
38
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.2.20
3
+ Version: 1.2.21
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  Provides-Extra: devs
@@ -54,10 +54,12 @@ oarepo_runtime/i18n/ui_schema.py
54
54
  oarepo_runtime/i18n/validation.py
55
55
  oarepo_runtime/relations/__init__.py
56
56
  oarepo_runtime/relations/base.py
57
+ oarepo_runtime/relations/components.py
57
58
  oarepo_runtime/relations/internal.py
58
59
  oarepo_runtime/relations/lookup.py
59
60
  oarepo_runtime/relations/mapping.py
60
61
  oarepo_runtime/relations/pid_relation.py
62
+ oarepo_runtime/relations/uow.py
61
63
  oarepo_runtime/tasks/__init__.py
62
64
  oarepo_runtime/tasks/datastreams.py
63
65
  oarepo_runtime/ui/__init__.py
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = oarepo-runtime
3
- version = 1.2.20
3
+ version = 1.2.21
4
4
  description = A set of runtime extensions of Invenio repository
5
5
  authors = Alzbeta
6
6
  readme = README.md
@@ -1,3 +0,0 @@
1
- from .dates import validate_date, validate_datetime
2
-
3
- __all__ = ["validate_date", "validate_datetime"]
File without changes