mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Cascade for restricted token view-table/view-database/view-instance operations (#2154)
Closes #2102 * Permission is now a dataclass, not a namedtuple - refs https://github.com/simonw/datasette/pull/2154/#discussion_r1308087800 * datasette.get_permission() method
This commit is contained in:
parent
a1f3d75a52
commit
50da908213
8 changed files with 427 additions and 50 deletions
|
|
@ -431,6 +431,20 @@ class Datasette:
|
|||
self._root_token = secrets.token_hex(32)
|
||||
self.client = DatasetteClient(self)
|
||||
|
||||
def get_permission(self, name_or_abbr: str) -> "Permission":
|
||||
"""
|
||||
Returns a Permission object for the given name or abbreviation. Raises KeyError if not found.
|
||||
"""
|
||||
if name_or_abbr in self.permissions:
|
||||
return self.permissions[name_or_abbr]
|
||||
# Try abbreviation
|
||||
for permission in self.permissions.values():
|
||||
if permission.abbr == name_or_abbr:
|
||||
return permission
|
||||
raise KeyError(
|
||||
"No permission found with name or abbreviation {}".format(name_or_abbr)
|
||||
)
|
||||
|
||||
async def refresh_schemas(self):
|
||||
if self._refresh_schemas_lock.locked():
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue