djblets.features.registry¶
Registry for managing feature registrations.
-
class
FeaturesRegistry[source]¶ Bases:
djblets.registries.registry.RegistryA registry for instantiated features.
This manages all instances of
Featuresubclasses that the product has created, providing easy access to features for checking purposes.-
default_errors= {u'already_registered': _(u'Could not register feature %(item)s: This feature is already registered or its ID conflicts with another feature.'), u'attribute_registered': _(u'Could not register feature %(item)s: Another feature (%(duplicate)s) is already registered with the same feature ID.'), u'invalid_attribute': _(u'"%(attr_name)s" is not a registered lookup attribute.'), u'load_entry_point': _(u'Could not load entry point %(entry_point)s: %(error)s.'), u'missing_attribute': _(u'Could not register %(item)s: it does not have a "%(attr_name)s" attribute.'), u'not_registered': _(u'No item registered with %(attr_name)s = %(attr_value)s.'), u'unregister': _(u'Could not unregister feature %(item)s: This feature was not yet registered.')}[source]¶
-
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_feature(feature_id)[source]¶ Return the feature instance with the given ID.
Parameters: feature_id (unicode) – The ID of the feature to return. Returns: The feature instance matching the ID or Noneif not found.Return type: djblets.features.feature.Feature
-
-
get_features_registry()[source]¶ Return the global features registry.
The first time this is called, a
FeaturesRegistrywill be instantiated and cached for future calls.Returns: The features registry. Return type: FeaturesRegistry