2.2 KiB
Patterns for Enabling
The entry point registry maintained by setuptools lists the available plugins, but does not provide a way for the end-user to control which are used or enabled. The common patterns for managing the set of extensions to be used are described below.
Enabled Through Installation
For many applications, simply installing an extension is enough of an indication that the extension should be used. No explicit configuration is required on the part of the user to either discover or enable the extension, since its entry point can be discovered when all of the plugins are loaded at runtime.
Examples of enabling through installation include:
Enabled Explicitly
In other cases, the extensions may be installed system-wide but should not all be enabled for a given application or instance of an application. In these situations, the person deploying or using the application will want to select the extensions to be used through an explicit configuration step.
Examples of explicitly enabled extensions include:
stevedore.named.NamedExtensionManager
Self-Enabled
Finally, some applications ask their extensions whether they should be enabled. The extension may look at other libraries installed on the system, check an external configuration setting, or examine a resource to see if it can be managed by the plugin. These checks are usually at runtime, either when the extension is loaded or when the user tries to access a specific resource.
Examples of self-enabled extensions include:
stevedore.enabled.EnabledExtensionManager