-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.py
43 lines (28 loc) · 967 Bytes
/
interfaces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from __future__ import annotations
from typing import TypeVar
t = TypeVar("t", bound="Identifiable")
v = TypeVar("v")
class Identifiable:
"""
An interface to mark database classes that have an id and can be identified by it.
Used in :ref:`.Namespace.database_searcher`
"""
not_found_text: str = ""
def __init__(self, **kwargs):
pass
@classmethod
def find_by_id(cls: type[t], entry_id: int) -> t | None:
raise NotImplementedError
class UserRole:
"""
An interface to mark database classes as user roles, that can be used for authorization.
Used in :ref:`.Namespace.jwt_authorizer`
"""
unauthorized_error: tuple[int | str, str] = (403, "Permission denied")
def __init__(self, **kwargs):
pass
@classmethod
def find_by_identity(cls: type[t], identity: v) -> t | None:
raise NotImplementedError
def get_identity(self) -> v:
raise NotImplementedError