Description
Description
Coldfront's current plugin mechanism is based on creating standalone Django apps and then requires the following modifications to the coldfront codebase:
- editing
coldfront/config/urls.py
to configure urlpaths. - adding settings for the plugin to
coldfront/config/plugins
. - editing
coldfront/config/settings.py
to import the app settings.
The need to edit files within the coldfront codebase presents challenges for both development of plugins and for deployment of coldfront instances with third party plugins. For instance see ImperialCollegeLondon/coldfront_development_environment for an example of the additional infrastructure required to create a reproducible development environment.
Improving the above boils down to improving the handling of settings and url patterns for plugins.
Settings
A fundamental question here is why include settings from plugins at all? The current scheme promotes a pattern of plugins having access to the global settings which is not modular. It should be possible to set configuration for plugins from the global settings but I'd argue plugins in general shouldn't be changing global settings as this could lead to conflicts and unexpected behaviour.
A model to recommend to plugins for handling settings might be how django-debug-toolbar does things. It is a standalone app that has an internal settings module. Settings are accessed within the app via settings.get_config which loads a set of default app settings and overrides them based on values from the global settings.
URL Patterns
As there is a standard location (urls.py
) for apps to define urlpatterns, their discovery and loading could be automated relatively easily via some importlib magic and (in the case of pip installed plugins) via entrypoints. Loading could be predicated on whether an app has been added to INSTALLED_APPS.
Component
Other
Additional information
No response