datasette/datasette/utils
Brandon Roberts baf986c871
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
2021-06-26 15:24:54 -07:00
..
__init__.py New get_metadata() plugin hook for dynamic metadata 2021-06-26 15:24:54 -07:00
asgi.py Applied Black 2021-01-11 13:34:38 -08:00
internal_db.py Prettier CREATE TABLE SQL for _internal 2020-12-22 15:55:43 -08:00
shutil_backport.py Backport of Python 3.8 shutil.copytree, refs #744 (#769) 2020-05-27 11:17:43 -07:00
sqlite.py Show pysqlite3 version on /-/versions, if installed - #1125 2020-12-03 14:08:50 -08:00
testing.py Make custom pages compatible with base_url setting 2021-06-05 11:59:54 -07:00