diff options
author | Matthias Baumgartner <dev@igsor.net> | 2023-03-01 12:39:42 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2023-03-01 12:39:42 +0100 |
commit | f9eec185bf3d857c220e5d78de75ec6713437330 (patch) | |
tree | e59a4a0fa57f3602e774891ebe4dba52b7518a7a /bsfs/graph/ac | |
parent | 9b490d19dcebc0fc24cb2ab89a783f1f7d6147f7 (diff) | |
download | bsfs-f9eec185bf3d857c220e5d78de75ec6713437330.tar.gz bsfs-f9eec185bf3d857c220e5d78de75ec6713437330.tar.bz2 bsfs-f9eec185bf3d857c220e5d78de75ec6713437330.zip |
Construct Graph and Nodes with AC instead of user
Diffstat (limited to 'bsfs/graph/ac')
-rw-r--r-- | bsfs/graph/ac/base.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/bsfs/graph/ac/base.py b/bsfs/graph/ac/base.py index 79b09e5..0b9f988 100644 --- a/bsfs/graph/ac/base.py +++ b/bsfs/graph/ac/base.py @@ -12,7 +12,7 @@ import typing from bsfs import schema from bsfs.query import ast from bsfs.triple_store import TripleStoreBase -from bsfs.utils import URI +from bsfs.utils import URI, typename # exports __all__: typing.Sequence[str] = ( @@ -44,6 +44,20 @@ class AccessControlBase(abc.ABC): self._backend = backend self._user = URI(user) + def __str__(self) -> str: + return f'{typename(self)}({self._user})' + + def __repr__(self) -> str: + return f'{typename(self)}({self._user})' + + def __eq__(self, other: typing.Any) -> bool: + return isinstance(other, type(self)) \ + and self._backend == other._backend \ + and self._user == other._user + + def __hash__(self) -> int: + return hash((type(self), self._backend, self._user)) + @abc.abstractmethod def is_protected_predicate(self, pred: schema.Predicate) -> bool: """Return True if a predicate cannot be modified manually.""" |