djblets.features.checkers¶
-
class
BaseFeatureChecker[source]¶ Bases:
objectBase class for a feature checker.
Subclasses are responsible for overriding
is_feature_enabled()and returning a suitable result for any given feature.-
min_enabled_level[source]¶ Decorator that converts a method with a single self argument into a property cached on the instance.
-
-
class
SettingsFeatureChecker[source]¶ Bases:
djblets.features.checkers.BaseFeatureCheckerFeature checker that checks against a SiteConfiguration.
This feature checker will check if a feature is enabled by checking the the
settings.ENABLED_FEATURESdictionary. This key can be changed by subclassing and modifyingsettings_key.
-
class
SiteConfigFeatureChecker[source]¶ Bases:
djblets.features.checkers.SettingsFeatureCheckerFeature checker that checks against a SiteConfiguration.
This feature checker will check two places to see if a feature is enabled:
- The
enabled_featuresdictionary in aSiteConfigurationsettings. - The
settings.ENABLED_FEATURESdictionary.
These keys can be changed by subclassing and modifying
siteconfig_keyandsettings_key.-
is_feature_enabled(feature_id, **kwargs)[source]¶ Return whether a feature is enabled for a given ID.
The feature will be enabled if its feature ID is set to
Truein either theenabled_featureskey in aSiteConfigurationor in asettings.ENABLED_FEATURESdictionary.Parameters: Returns: A boolean value indicating if the feature is enabled.
Return type:
- The
-
set_feature_checker(feature_checker)[source]¶ Set the feature checker to use for all features.
This can be called to manually configure a feature checker, or to unset the feature checker in order to recompute it.
Parameters: feature_checker (BaseFeatureChecker) – The new feature checker to set, or Noneto unset.
-
get_feature_checker()[source]¶ Return the configured feature checker instance.
The class to use is configured through the
settings.FEATURE_CHECKERsetting, which must be a full module and class path. If not specified,SettingsFeatureCheckerwill be used.The same feature checker instance will be returned each time this is called.
Returns: A feature checker instance. Return type: BaseFeatureChecker Raises: django.core.exceptions.ImproperlyConfigured– There was an error either in thesettings.FEATURE_CHECKERvalue or in instantiating the feature checker.