Entity Registry¶
-
class
keg_auth.model.entity_registry.
EntityRegistry
(user=None, permission=None, bundle=None, group=None, attempt=None)¶ Registry cache that identifies entities for particular usage/function in KegAuth.
KegAuth does not provide its own entities for the database model. Instead, mixins are given so that an application can customize as needed. To support this model and still know what entity to use, we register it in an EntityRegistry.
Entities may be registered in one of two ways: - Mark an entity with a registration decorator:
@registry.register_user class User(UserMixin, db.EntityBase): pass
Pass the entity into the EntityRegistry constructor:
registry = EntityRegistry(user=User, permission=Permission, ...)
Registered entities may be subsequently referenced via the properties, e.g.
registry.user_cls-
attempt_cls
¶ Return the entity registered for Attempt.
-
bundle_cls
¶ Return the entity registered for Bundle.
-
group_cls
¶ Return the entity registered for Group.
-
is_registered
(type)¶ Helper for determining if functionality is unlocked via a registered entity.
-
permission_cls
¶ Return the entity registered for Permission.
-
register_attempt
(cls)¶ Mark given class as the entity for Attempt.
-
register_bundle
(cls)¶ Mark given class as the entity for Bundle.
-
register_group
(cls)¶ Mark given class as the entity for Group.
-
register_permission
(cls)¶ Mark given class as the entity for Permission.
-
register_user
(cls)¶ Mark given class as the entity for User.
-
user_cls
¶ Return the entity registered for User.
-
exception
keg_auth.model.entity_registry.
RegistryError
¶