Merge branch 'main' into codex/test-write-wrapper-alter-rollback

This commit is contained in:
Simon Willison 2026-09-16 14:42:20 -07:00 • committed by GitHub
commit 0d0bb5dd8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 137 additions and 8 deletions

View file

@ -27,6 +27,8 @@ Bug fixes
~~~~~~~~~
- The :ref:`alter-table API <TableAlterView>` now rolls back schema changes when a :ref:`write_wrapper <plugin_hook_write_wrapper>` raises after the write. (:issue:`2924`, :pr:`2925`)
- The :ref:`extra_template_vars() <plugin_hook_extra_template_vars>` plugin hook can now return a function or awaitable that resolves to ``None`` when no extra variables are needed. (:issue:`2005`)
- :ref:`request.headers <internals_request>` now supports case-insensitive header lookups, so ``request.headers.get("Content-Type")`` works as well as ``request.headers.get("content-type")``. (:issue:`1861`)
- CSV endpoints now return plain-text error messages for SQL errors. (:issue:`2129`)
- The :ref:`render_cell() <plugin_hook_render_cell>` plugin hook now receives an empty ``pks`` list when rendering SQL views in HTML, matching the JSON ``?_extra=render_cell`` behavior. (:issue:`2639`)
- Numeric comparison filters now correctly handle decimal values, negative numbers and scientific notation when filtering computed columns and SQL views. Thanks, `Rami Abdelrazzaq <https://github.com/RamiNoodle733>`__. (:issue:`1681`, :pr:`2876`)

View file

@ -26,7 +26,7 @@ The request object is passed to various plugin hooks. It represents an incoming
The request scheme - usually ``https`` or ``http``.
``.headers`` - dictionary (str -> str)
A dictionary of incoming HTTP request headers. Header names have been converted to lowercase.
A dictionary of incoming HTTP request headers. Header lookups using ``request.headers["Content-Type"]``, ``request.headers.get("Content-Type")`` and ``"Content-Type" in request.headers`` are case-insensitive. Header names are lowercase when iterating over the dictionary.
``.cookies`` - dictionary (str -> str)
A dictionary of incoming cookies

View file

@ -217,7 +217,7 @@ Extra template variables that should be made available in the rendered template
``datasette`` - :ref:`internals_datasette`
You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``
This hook can return one of three different types:
This hook supports the following return values:
Dictionary
If you return a dictionary its keys and values will be merged into the template context.
@ -228,6 +228,9 @@ Function that returns a dictionary
Function that returns an awaitable function that returns a dictionary
You can also return a function which returns an awaitable function which returns a dictionary.
``None``
The hook itself, or a function or awaitable it returns, can return ``None`` when no extra variables are needed. Variables returned by other plugins are still included.
Datasette runs Jinja2 in `async mode <https://jinja.palletsprojects.com/en/2.10.x/api/#async-support>`__, which means you can add awaitable functions to the template scope and they will be automatically awaited when they are rendered by the template.
.. warning::
@ -254,8 +257,6 @@ This example returns an awaitable function which adds a list of ``hidden_table_n
return {
"hidden_table_names": await db.hidden_table_names()
}
else:
return {}
return hidden_table_names