Wraps list-based settings to provide management and ref counting.
This can be used instead of direct access to a list in Django settings to ensure items are never added more than once, and only removed when nothing needs it anymore.
Each item in the list is ref-counted. The initial items from the setting are populated and start with a ref count of 1. Adding items will increment a ref count for the item, adding it to the list if it doesn’t already exist. Removing items reduces the ref count, removing when it hits 0.
Adds an item to the setting.
If the item is already in the list, it won’t be added again. The ref count will just be incremented.
If it’s a new item, it will be added to the list with a ref count of 1.
Adds a list of items to the setting.
Removes an item from the setting.
The item’s ref count will be decremented. If it hits 0, it will be removed from the list.
Removes a list of items from the setting.
A manager for all extensions.
ExtensionManager manages the extensions available to a project. It can scan for new extensions, enable or disable them, determine dependencies, install into the database, and uninstall.
An installed extension is one that has been installed by a Python package on the system.
A registered extension is one that has been installed and information then placed in the database. This happens automatically after scanning for an installed extension. The registration data stores whether or not it’s enabled, and stores various pieces of information on the extension.
An enabled extension is one that is actively enabled and hooked into the project.
Each project should have one ExtensionManager.
Returns the URL patterns for the Extension Manager.
This should be included in the root urlpatterns for the site.
Returns whether or not the extension state is possibly expired.
Extension state covers the lists of extensions and each extension’s configuration. It can expire if the state synchronization value falls out of cache or is changed.
Each ExtensionManager has its own state synchronization cache key.
Returns an enabled extension with the given ID.
Returns the list of all enabled extensions.
Returns the list of all installed extensions.
Returns the installed extension with the given ID.
Returns a list of all extensions required by an extension.
Enables an extension.
Enabling an extension will install any data files the extension may need, any tables in the database, perform any necessary database migrations, and then will start up the extension.
Disables an extension.
Disabling an extension will remove any data files the extension installed and then shut down the extension and all of its hooks.
It will not delete any data from the database.
Install an extension from a remote source.
Installs an extension from a remote URL containing the extension egg. Installation may fail if a malformed install_url or package_name is passed, which will cause an InstallExtensionError exception to be raised. It is also assumed that the extension is not already installed.
Loads all known extensions, initializing any that are recorded as being enabled.
If this is called a second time, it will refresh the list of extensions, adding new ones and removing deleted ones.
If full_reload is passed, all state is cleared and we reload all extensions and state from scratch.
Shut down the extension manager and all of its extensions.
Installs extension static media.
This method is a wrapper around _install_extension_media_internal to check whether we actually need to install extension media, and avoid contention among multiple threads/processes when doing so.
We need to install extension media if it hasn’t been installed yet, or if the version of the extension media that we installed is different from the current version of the extension.
Return all extension manager instances.
This will return all the extension managers that have been constructed. The order is not guaranteed.
Returns: The list of ExtensionManager instances. Return type: list
Shut down all extension managers.
This is called automatically when the process exits, but can be run manually.