Jump to >

djblets.registries.mixins

Utility mixins for registries.

class ExceptionFreeGetterMixin[source]

Bases: Generic[djblets.registries.registry.RegistryItemType]

A mixin that prevents lookups from throwing errors.

If using typed registries and inheriting from this mixin, the same type should be passed to this class as well.

This class may be deprecated in the future. Callers may want to switch to calling Registry.get_or_none() instead, which offers the same functionality.

Changed in version 3.1: Added support for specifying a registry item type when subclassing this mixin.

__annotations__ = {}
__orig_bases__ = (typing.Generic[~RegistryItemType],)
__parameters__ = (~RegistryItemType,)
get(attr_name: str, attr_value: object) Optional[djblets.registries.registry.RegistryItemType][source]

Return the requested registered item.

Parameters
  • attr_name (str) – The attribute name.

  • attr_value (object) – The attribute value.

Returns

The matching registered item, if found. Otherwise, None is returned.

Return type

object