Skip to content

Commit

Permalink
(format fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoxos committed Nov 26, 2024
1 parent 8b59ba9 commit 705b938
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mupifDB/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ def has(self, obj: Any, perm: _PermWhat='read', on: _PermOn='self') -> bool:
return True
def ensure(self, obj: T, perm:_PermWhat='read', on: _PermOn='self',diag: str|None=None) -> T:
'Check permissions on the object (read on obj by default) and return it. Raise ForbiddenError if the check fails.'
# if obj.parent is None: raise ForbiddenError(f'{obj.__class__.__name__}(dbID={obj.dbID}).parent is None!')
if not self.has(obj=obj,perm=perm, on=on):
raise ForbiddenError('Forbidden {perm} access to {"the parent of" if on=="parent" else ""} {obj.__class__.__name__}(dbID={obj.dbID}){": "+diag if diag else ""}.')
raise ForbiddenError(f'Forbidden {perm} access to {"the parent of" if on=="parent" else ""} {obj.__class__.__name__}(dbID={obj.dbID}){": "+diag if diag else ""}.')
return obj
def TODO(*args,**kw): pass
def filterSelfRead(self,objs: List[T]) -> List[T]: return [obj for obj in objs if self.has(obj,perm='read',on='self')]
Expand Down

0 comments on commit 705b938

Please sign in to comment.