WIP table_filter plugin hook

This commit is contained in:
Simon Willison 2018-08-05 12:59:45 -07:00
commit 5116c4ec8a
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
4 changed files with 48 additions and 5 deletions

View file

@ -320,3 +320,28 @@ If the value matches that pattern, the plugin returns an HTML link element:
href=jinja2.escape(data["href"]),
label=jinja2.escape(data["label"] or "") or " "
))
table_filter
~~~~~~~~~~~~
Apply additional SQL filters to the current table based on the request.
This should return an awaitable function with the following signature:
.. code-block:: python
from datasette.utils import TableFilter
@hookimpl
def table_filter():
async def inner(view, name, table, request):
extra_human_descriptions = []
where_clauses = []
params = {}
# ... build those things here
return TableFilter(
human_description_extras=extra_human_descriptions,
where_clauses=where_clauses,
params=params,
)
return inner