-
-
Notifications
You must be signed in to change notification settings - Fork 697
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
datasette.add_message() doesn't work inside plugins #864
Comments
Urgh, fixing this is going to be a bit of a pain. Here's where I added that custom If I want this to be made available to Currently Lines 1057 to 1068 in 1a5b7d3
So I'm going to have to refactor this quite a bit to get that shared request object which can be passed both to |
The ideal fix here would be to rework my |
|
Re-opening: plugins may get to set messages but they don't display them, even if they render a template that extends return Response.html(
await datasette.render_template(
"write.html",
{"databases": databases, "sql": request.args.get("sql") or ""},
request=request,
)
) This won't display messages. The reason is that the messages are made available to the template context in the datasette/datasette/views/base.py Lines 87 to 95 in 7ac4936
|
I think the fix is to move the Lines 735 to 748 in 7ac4936
|
To test this I'll need a plugin test that renders a custom template. Here's an example I can imitate: datasette/tests/test_plugins.py Lines 588 to 596 in 7ac4936
|
Similar problem to #863 - calling
datasette.add_message()
in a view registered using theregister_routes()
plugin hook doesn't work, because the code that writes accumulated messages to theds_messages
signed cookie lives in theBaseView
class here:datasette/datasette/views/base.py
Lines 94 to 97 in 28bb1c5
The text was updated successfully, but these errors were encountered: