-
-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extra_template_vars() sending wrong view_name for index #716
Comments
I think I'll use |
Once I fix this bug I should update https://github.com/simonw/museums to deploy using the latest Datasette release as opposed to being anchored to 286ed28. |
In order to use I'm going to use something I can execute with datasette/tests/test_plugins.py Lines 205 to 227 in 7656fd6
|
OK, here's the test harness. Three files:
import asyncio
import pathlib
from datasette.app import Datasette
import httpx
root = pathlib.Path(__file__).parent
async def run_check():
ds = Datasette(
[], template_dir=str(root / "templates"), plugins_dir=str(root / "plugins")
)
async with httpx.AsyncClient(app=ds.app()) as client:
response = await client.get("http://localhost/")
assert 200 == response.status_code
assert b"view_name:index" == response.content, response.content
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(run_check())
from datasette import hookimpl
@hookimpl
def extra_template_vars(view_name):
return {"view_name": view_name} |
|
You start
Then you tell it to start running your script:
Here's what I got:
So 70b915f introduced the bug! |
Found it. Prior to that change I passed datasette/datasette/views/base.py Lines 114 to 132 in 286ed28
I switched over to doing this: datasette/datasette/views/base.py Lines 95 to 97 in 07e208c
But forgot to pass in the optional Lines 554 to 556 in 2aaad72
Next step: write a failing test, then fix it. |
The test ended up being a bit fiddly - here it is: datasette/tests/test_plugins.py Lines 266 to 317 in 0925381
I used In writing this I realized that the datasette/datasette/views/database.py Lines 27 to 31 in 0925381
datasette/datasette/views/table.py Lines 224 to 227 in 07e208c
So I removed the |
See simonw/museums#20 (comment) - at some point between 286ed28 and current master (e0e7a0f today) a bug was introduced where the
extra_template_vars(request, view_name)
plugin hook started being passedNone
instead ofindex
for theview_name
parameter on the site index page.The text was updated successfully, but these errors were encountered: