mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
table_config instead of table_metadata (#2257)
Table configuration that was incorrectly placed in metadata is now treated as if it was in config. New await datasette.table_config() method. Closes #2247
This commit is contained in:
parent
52a1dac5d2
commit
60c6692f68
6 changed files with 175 additions and 30 deletions
|
|
@ -75,6 +75,7 @@ from .utils import (
|
|||
format_bytes,
|
||||
module_from_path,
|
||||
move_plugins,
|
||||
move_table_config,
|
||||
parse_metadata,
|
||||
resolve_env_secrets,
|
||||
resolve_routes,
|
||||
|
|
@ -346,7 +347,9 @@ class Datasette:
|
|||
# Move any "plugins" settings from metadata to config - updates them in place
|
||||
metadata = metadata or {}
|
||||
config = config or {}
|
||||
move_plugins(metadata, config)
|
||||
metadata, config = move_plugins(metadata, config)
|
||||
# Now migrate any known table configuration settings over as well
|
||||
metadata, config = move_table_config(metadata, config)
|
||||
|
||||
self._metadata_local = metadata or {}
|
||||
self.sqlite_extensions = []
|
||||
|
|
@ -1202,10 +1205,11 @@ class Datasette:
|
|||
def _actor(self, request):
|
||||
return {"actor": request.actor}
|
||||
|
||||
async def table_config(self, database, table):
|
||||
"""Fetch table-specific metadata."""
|
||||
async def table_config(self, database: str, table: str) -> dict:
|
||||
"""Return dictionary of configuration for specified table"""
|
||||
return (
|
||||
(self.metadata("databases") or {})
|
||||
(self.config or {})
|
||||
.get("databases", {})
|
||||
.get(database, {})
|
||||
.get("tables", {})
|
||||
.get(table, {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue