inveniosoftware / troubleshooting

DEPRECATED - Use the forum instead:
https://invenio-talk.web.cern.ch
5 stars 4 forks source link

invenio-userprofiles: settings template not set #30

Open zzacharo opened 6 years ago

zzacharo commented 6 years ago

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 the SETTINGS_TEMPLATE variable from invenio-theme was missing because the latter initialized after. We should check if invenio-userprofiles should depend on invenio-theme extension so we won't have this issue. The solution to this is to put the SETTINGS_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

lnielsen commented 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).

zzacharo commented 6 years ago

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?

lnielsen commented 6 years ago

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:

  1. [NEW] Load configuration from invenio_config.ext_module entry point group.
  2. Load configuration from invenio_config.module entry point group (i.e. for site configuration).
  3. Load configuration from config module if provided as an argument.
  4. Load configuration from the instance folder: /.cfg.
  5. Load configuration keyword arguments provided.
  6. Load configuration from environment variables with the prefix env_prefix.

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.

zzacharo commented 6 years ago

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.