mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Implemented actor_from_request with tests, refs #699
Also added datasette argument to permission_allowed hook
This commit is contained in:
parent
060a56735c
commit
461c82838d
6 changed files with 80 additions and 2 deletions
|
|
@ -126,3 +126,11 @@ class DummyFacet(Facet):
|
|||
facet_results = {}
|
||||
facets_timed_out = []
|
||||
return facet_results, facets_timed_out
|
||||
|
||||
|
||||
@hookimpl
|
||||
def actor_from_request(datasette, request):
|
||||
if request.args.get("_bot"):
|
||||
return {"id": "bot"}
|
||||
else:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -95,3 +95,15 @@ def asgi_wrapper(datasette):
|
|||
return add_x_databases_header
|
||||
|
||||
return wrap_with_databases_header
|
||||
|
||||
|
||||
@hookimpl
|
||||
def actor_from_request(datasette, request):
|
||||
async def inner():
|
||||
if request.args.get("_bot2"):
|
||||
result = await datasette.get_database().execute("select 1 + 1")
|
||||
return {"id": "bot2", "1+1": result.first()[0]}
|
||||
else:
|
||||
return None
|
||||
|
||||
return inner
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue