Skip to content

Commit

Permalink
entrypoint for each profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Alzbeta Pokorna committed Jan 17, 2025
1 parent 1d99598 commit 0b769a0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ class InvenioRecordResourceConfigBuilder(InvenioBaseClassPythonBuilder):
TYPE = "invenio_record_resource_config"
section = "resource-config"
template = "resource-config"

def finish(self, **extra_kwargs):
profile = self.current_model.profile
super().finish(profile=profile, **extra_kwargs)
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import importlib_metadata
from flask_resources import ResponseHandler

{{ vars.json_serializer.class|imports }}
{{ vars.resource_config|imports }}

class {{ vars.resource_config|class_header }}:
"""{{ vars.record.class|base_name }} resource config."""
Expand All @@ -24,7 +22,7 @@ class {{ vars.resource_config|class_header }}:
@property
def error_handlers(self):
entrypoint_error_handlers = {}
for x in importlib_metadata.entry_points(group='invenio.{{ vars.module.qualified }}.error_handlers'):
for x in importlib_metadata.entry_points(group='invenio.{{ vars.module.qualified }}_{{ profile }}.error_handlers'):
entrypoint_error_handlers.update(x.load())
return {
**super().error_handlers,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-model-builder
version = 4.0.101
version = 4.0.102
description = A utility library that generates OARepo required data model files from a JSON specification file
authors = Miroslav Bauer <[email protected]>, Miroslav Simek <[email protected]>
readme = README.md
Expand Down
2 changes: 1 addition & 1 deletion tests/test_simple_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_resource_config_builder():
[InvenioRecordResourceConfigBuilder],
os.path.join("test", "resources", "records", "config.py"),
)

print(data)
assert strip_whitespaces(data) == strip_whitespaces(
'''
import importlib_metadata
Expand Down

0 comments on commit 0b769a0

Please sign in to comment.