write_wrapper plugin hook for intercepting write operations
A new write_wrapper() plugin hook allows plugins to intercept and wrap database write operations. (#2636)
Plugins implement the hook as a generator-based context manager:
@hookimpl
def write_wrapper(datasette, database, request):
def wrapper(conn):
# Setup code runs before the write
yield
# Cleanup code runs after the write
return wrapperregister_token_handler() plugin hook for custom API token backends
A new register_token_handler() plugin hook allows plugins to provide custom token backends for API authentication. (#2650)
This includes a backwards incompatible change: the datasette.create_token() internal method is now an async method. Consult the upgrade guide for details on how to update your code.
render_cell() now receives a pks parameter
The render_cell() plugin hook now receives a pks parameter containing the list of primary key column names for the table being rendered. This avoids plugins needing to make redundant async calls to look up primary keys. (#2641)
Other changes
- Facets defined in metadata now preserve their configured order, instead of being sorted by result count. Request-based facets added via the
_facetparameter are still sorted by result count and appear after metadata-defined facets. (#2647) - Fixed
--reloadincorrectly interpreting theservecommand as a file argument. Thanks, Daniel Bates. (#2646)