Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service kwargs fix #284

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions oarepo_model_builder/invenio/templates/ext_resource.py.jinja2
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from functools import cached_property
{{ vars.config.module|generate_import(alias='config') }}

{% for extra_field_value in ext.service_kwargs.values() %}
{{ extra_field_value|code_imports }}
{% endfor %}

class {{ vars.ext|class_header }}:
{% if not vars.service.skip %}
@cached_property
def {{ ext.ext_service_name }}(self):
service_config = config.{{ vars.service_config.config_key }}
service_kwargs = {{ ext.service_kwargs }}
if hasattr(service_config, "build"):
config_class = service_config.build(self.app)
else:
config_class = service_config()
service_kwargs["config"] = config_class

service_kwargs = {
{% for kwarg_name, kwarg_def in ext.service_kwargs.items() %}
"{{ kwarg_name }}": {{ kwarg_def | extra_code}},
{% endfor %}
"config": config_class
}
return config.{{ vars.service.config_key }}(
**service_kwargs,
{% if vars.service.additional_args %}
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.97
version = 4.0.98
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
Loading