djblets.features.registry¶
Registry for managing feature registrations.
- class FeaturesRegistry[source]¶
A registry for instantiated features.
This manages all instances of
Feature
subclasses that the product has created, providing easy access to features for checking purposes.- register(feature)[source]¶
Register a feature instance.
The feature’s
initialize()
method will be called once registered.- Parameters
feature (djblets.features.feature.Feature) – The feature to register.
- Raises
djblets.features.errors.FeatureConflictError – The feature’s ID conflicts with another feature class.
djblets.registries.errors.RegistrationError – The feature ID wasn’t set on the class.
- unregister(feature)[source]¶
Unregister a feature instance.
The feature’s
shutdown()
method will be called once unregistered.- Parameters
feature (djblets.features.feature.Feature) – The feature to unregister.
- Raises
djblets.features.errors.FeatureNotFoundError – Raised if the feature was not already registered.
- get_features_registry()[source]¶
Return the global features registry.
The first time this is called, a
FeaturesRegistry
will be instantiated and cached for future calls.- Returns
The features registry.
- Return type