mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New get_metadata() plugin hook for dynamic metadata
The following hook is added:
get_metadata(
datasette=self, key=key, database=database, table=table,
fallback=fallback
)
This gets called when we're building our metdata for the rest
of the system to use. We merge whatever the plugins return
with any local metadata (from metadata.yml/yaml/json) allowing
for a live-editable dynamic Datasette.
As a security precation, local meta is *not* overwritable by
plugin hooks. The workflow for transitioning to live-meta would
be to load the plugin with the full metadata.yaml and save.
Then remove the parts of the metadata that you want to be able
to change from the file.
* Avoid race condition: don't mutate databases list
This avoids the nasty "RuntimeError: OrderedDict mutated during
iteration" error that randomly happens when a plugin adds a
new database to Datasette, using `add_database`. This change
makes the add and remove database functions more expensive, but
it prevents the random explosion race conditions that make for
confusing user experience when importing live databases.
Thanks, @brandonrobertz
This commit is contained in:
parent
953a64467d
commit
baf986c871
7 changed files with 114 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -117,3 +117,4 @@ ENV/
|
|||
# macOS files
|
||||
.DS_Store
|
||||
node_modules
|
||||
.*.swp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue