diff --git a/oarepo_model_builder/invenio/invenio_record_resource_config.py b/oarepo_model_builder/invenio/invenio_record_resource_config.py index 3eed535..410e699 100644 --- a/oarepo_model_builder/invenio/invenio_record_resource_config.py +++ b/oarepo_model_builder/invenio/invenio_record_resource_config.py @@ -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) \ No newline at end of file diff --git a/oarepo_model_builder/invenio/templates/resource_config.py.jinja2 b/oarepo_model_builder/invenio/templates/resource_config.py.jinja2 index a810174..fa96bb0 100644 --- a/oarepo_model_builder/invenio/templates/resource_config.py.jinja2 +++ b/oarepo_model_builder/invenio/templates/resource_config.py.jinja2 @@ -21,4 +21,14 @@ class {{ vars.resource_config|class_header }}: **entrypoint_response_handlers } + @property + def error_handlers(self): + entrypoint_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, + **entrypoint_error_handlers + } + {{ vars.resource_config|extra_code }} \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 230fd53..c0a9411 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 , Miroslav Simek readme = README.md diff --git a/tests/test_simple_builders.py b/tests/test_simple_builders.py index 0c53888..e570f10 100644 --- a/tests/test_simple_builders.py +++ b/tests/test_simple_builders.py @@ -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 @@ -349,6 +349,16 @@ def response_handlers(self): **super().response_handlers, **entrypoint_response_handlers } + + @property + def error_handlers(self): + entrypoint_error_handlers = {} + for x in importlib_metadata.entry_points(group='invenio.test_record.error_handlers'): + entrypoint_error_handlers.update(x.load()) + return { + **super().error_handlers, + **entrypoint_error_handlers + } ''' )