mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Refactor check_visibility() to use Resource objects, refs #2537
Updated check_visibility() method signature to accept Resource objects (DatabaseResource, TableResource, QueryResource) instead of plain strings and tuples. Changes: - Updated check_visibility() signature to only accept Resource objects - Added validation with helpful error message for incorrect types - Updated all check_visibility() calls throughout the codebase: - datasette/views/database.py: Use DatabaseResource and QueryResource - datasette/views/special.py: Use DatabaseResource and TableResource - datasette/views/row.py: Use TableResource - datasette/views/table.py: Use TableResource - datasette/app.py: Use TableResource in expand_foreign_keys - Updated tests to use Resource objects - Updated documentation in docs/internals.rst: - Removed outdated permissions parameter - Updated examples to use Resource objects 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
653475edde
commit
95286fbb60
7 changed files with 34 additions and 47 deletions
|
|
@ -5,6 +5,7 @@ Tests for the datasette.app.Datasette class
|
|||
import dataclasses
|
||||
from datasette import Forbidden, Context
|
||||
from datasette.app import Datasette, Database
|
||||
from datasette.resources import DatabaseResource
|
||||
from itsdangerous import BadSignature
|
||||
import pytest
|
||||
|
||||
|
|
@ -93,7 +94,7 @@ ALLOW_ROOT = {"allow": {"id": "root"}}
|
|||
None,
|
||||
{"databases": {"_memory": ALLOW_ROOT}},
|
||||
"view-database",
|
||||
"_memory",
|
||||
DatabaseResource(database="_memory"),
|
||||
False,
|
||||
False,
|
||||
),
|
||||
|
|
@ -101,7 +102,7 @@ ALLOW_ROOT = {"allow": {"id": "root"}}
|
|||
ROOT,
|
||||
{"databases": {"_memory": ALLOW_ROOT}},
|
||||
"view-database",
|
||||
"_memory",
|
||||
DatabaseResource(database="_memory"),
|
||||
True,
|
||||
True,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue