Skip to content

Commit

Permalink
build service
Browse files Browse the repository at this point in the history
  • Loading branch information
Alzbeta Pokorna authored and Alzbeta Pokorna committed Nov 15, 2024
1 parent 6ed10af commit a3696dd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions oarepo_model_builder/invenio/templates/ext.py.jinja2
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import re

from invenio_rdm_records.services.pids import PIDsService, PIDManager
{{ vars.config.module|generate_import(alias='config') }}
{{ vars.ext|imports }}

Expand Down Expand Up @@ -29,6 +31,8 @@ class {{ vars.ext|class_header }}:

def init_config(self, app):
"""Initialize configuration."""
{{ vars.service }}
{{ vars.ext }}
for identifier in dir(config):
if re.match('^[A-Z_0-9]*$', identifier) and not identifier.startswith('_'):
if isinstance(app.config.get(identifier), list):
Expand All @@ -55,4 +59,18 @@ class {{ vars.ext|class_header }}:
return True
return False

@cached_property
def service_records(self):
{{ vars.service_config.class|generate_import }}
{{ vars.service.class|generate_import }}
config_class = {{ vars.service_config.class|base_name }}.build(self.app)
return {{ vars.service.class|base_name }}(
config=config_class,
pids_service=PIDsService(config_class, PIDManager),
{% if vars.service.additional_args %}
{{ vars.service.additional_args|generate_list }}
{% endif %}
)


{{ vars.ext|extra_code }}

0 comments on commit a3696dd

Please sign in to comment.