-
Notifications
You must be signed in to change notification settings - Fork 86
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
Feature: Enhanced plugin system #627
Comments
Should add if you'd like to see a mockup for the urlpattern loading I'd be happy to knock together a PR. |
@cc-a Thanks for the detailed write up. Related to this, we're currently evaluating using DJP as it seems to be well polished and checks a lot of boxes in terms of providing an enhanced plug system. Perhaps we can use this issue to discuss pros/cons and other options for improving the way ColdFront can be extended. |
DJP looks interesting (I'm just annoyed it's not on the first page of google results for "django plugins" so I didn't come across it). Looks like it would neatly handle settings and urlpatterns whilst also potentially handling INSTALLED_APPS and MIDDLEWARE. A few thoughts on DJP:
|
Curious if you guys have any thoughts on this? Happy to implement mockups of one or more approaches that you think may be viable. |
I don't believe there is any specific use cases that would require plugins to modify global settings. Is the concern here that plugins could inadvertently modify some setting that they don't necessary own? DJP has this hook which passes in the current settings, are you suggesting this should not be allowed and instead only allow plugins to modify their own settings?
Yes, agree it would be a major breaking change. The thinking would be to create a new branch (likely v2.x) that would include these features as part of a new major release of ColdFront, which should allow plugin authors time to migrate/refactor changes.
That would be great. Think it would be worthwhile to see a mockup of how DJP could work in ColdFront and an a custom approach that borrows some of these ideas from the other plugin projects? Thoughts? |
I've put together a couple of PR's (#636 and #639) that compare using DJP with a hand rolled approach. They mostly end up doing a lot of the same things and djp makes it easier and provides a nicer user interface to developers. Overall the plugin system could be greatly simplified if explicit support for putting third party plugins in the If you're interested in pursuing either approach I'd be happy to write some follow on issues to get into the broader details of implementation. |
@cc-a Thanks SO much for this. We'll try and get these reviewed asap and get you some feedback.
Sounds good, I'm open to the pip based install method and makes a lot of sense. |
Description
Coldfront's current plugin mechanism is based on creating standalone Django apps and then requires the following modifications to the coldfront codebase:
coldfront/config/urls.py
to configure urlpaths.coldfront/config/plugins
.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
The text was updated successfully, but these errors were encountered: