Jump to >

djblets.privacy.consent.registry

Registry for things that require consent from a user.

class ConsentRequirementsRegistry[source]

Bases: djblets.registries.registry.OrderedRegistry

A registry for managing aspects of a product requiring consent.

Each requirement in the registry requires consent by the user before the action or processing for that requirement is allowed to occur.

lookup_attrs: Sequence[str] = ('requirement_id',)[source]

A list of attributes that items can be looked up by.

Type

list of str

already_registered_error_class[source]

alias of djblets.privacy.consent.errors.ConsentRequirementConflictError

lookup_error_class[source]

alias of djblets.privacy.consent.errors.ConsentRequirementNotFoundError

default_errors: Dict[str, str] = {'already_registered': 'Could not register consent requirement %(item)s: This requirement is already registered or its ID conflicts with another consent requirement.', 'attribute_registered': 'Could not register consent requirement %(item)s: Another requirement (%(duplicate)s) is already registered with the same ID.', 'invalid_attribute': '"%(attr_name)s" is not a registered lookup attribute.', 'load_entry_point': 'Could not load entry point %(entry_point)s: %(error)s.', 'missing_attribute': 'Could not register %(item)s: it does not have a "%(attr_name)s" attribute.', 'not_registered': 'No item registered with %(attr_name)s = %(attr_value)s.', 'unregister': 'Could not unregister consent requirement %(item)s: This requirement was not yet registered.'}[source]

The default error formatting strings.

If subclasses need to provide additional errors that can be overridden, they should copy DEFAULT_ERRORS and set their copy on the subclass as this attribute.

Type

dict

Return a consent requirement with the given ID.

Parameters

requirement_id (unicode) – The consent requirement ID to look up.

Returns

The resulting consent requirement, if found. If a requirement with this ID could not be found, this will return None.

Return type

djblets.privacy.consent.base.BaseConsentRequirement

__annotations__ = {'_by_id': 'Dict[int, RegistryItemType]', '_items': 'Set[RegistryItemType]', '_key_order': 'List[int]', '_populated': 'bool', '_registry': 'Dict[str, Dict[object, RegistryItemType]]', 'already_registered_error_class': 'Type[AlreadyRegisteredError]', 'default_errors': 'Dict[str, str]', 'errors': 'Dict[str, str]', 'item_name': 'Optional[str]', 'lookup_attrs': 'Sequence[str]', 'lookup_error_class': 'Type[ItemLookupError]'}
__parameters__ = ()

Return the registry for managing consent requirements.

Returns

The registry for consent requirements.

Return type

ConsentRequirementsRegistry