Open zzacharo opened 6 years ago
I think this is actually an issue that needs documentation in Invenio-Theme. Invenio instances should always specify their base template (see (example)[https://github.com/inveniosoftware/invenio-app-ils/blob/master/invenio_app_ils/config.py#L58-L69]). See also https://invenio-theme.readthedocs.io/en/latest/usage.html#base-template-pattern.
I don't think there's any pretty way around this. <NAME>_TEMPLATE
variables must be set prior to the Flask extension loading phase because extensions can be loaded in any order. The only way to set these config variables prior to the extension loading is in the (configuration loading phase)[http://invenio.readthedocs.io/en/latest/developersguide/application-architecture.html#assembly-phases] (i.e. putting SETTINGS_TEMPLATE
in your instance config).
Ok, so if there is no way to force extension initialization we should at least improve the documentation as you said! Or if we introduce a special configuration entrypoint that runs before the extension initialization phase in order to get the "critical" configuration variables? Could it be a nice solution?
Or if we introduce a special configuration entrypoint that runs before the extension initialization phase in order to get the "critical" configuration variables?
It might be done in the current configuration loader as the first step. I.e something like:
invenio_config.ext_module
entry point group.invenio_config.module
entry point group (i.e. for site configuration).Note that each step overwrites configuration from the previous step, thus step 0 would load configuration from Invenio-Theme, and step 1 would load it from e.g. cds_videos.config
and thus allow CDS to overwrite the Invenio-Theme SETTINGS_TEMPLATE
and other variables.
Yes that could be a solution but as I am thinking more about it I think we are gonna end to something similar of just havinig it in the instance configuration.
There was a weird issue in cds-videos qa and prod environment that is described by this issue https://github.com/CERNDocumentServer/cds-videos/issues/1440 . We found that during the initialisation of the extensions the order matters so when
invenio-userprofiles
was initialized theSETTINGS_TEMPLATE
variable frominvenio-theme
was missing because the latter initialized after. We should check ifinvenio-userprofiles
should depend oninvenio-theme
extension so we won't have this issue. The solution to this is to put theSETTINGS_TEMPLATE
variable in the cds app config but anyhow we should consider the other way.See the below links: https://github.com/inveniosoftware/invenio-userprofiles/blob/master/invenio_userprofiles/ext.py#L70 https://github.com/inveniosoftware/invenio-theme/blob/master/invenio_theme/config.py#L54