-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Custom response support via callback_context #623
Conversation
( | ||
'dash.callback_context.{} ' | ||
'is only available from a callback!' | ||
).format(getattr(func, '__name__')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change? I find that less readable. The parens are unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous one no longer fit in 80 characters when I fixed dash.callback
-> dash.callback_context
.
Also, not sure if this is a pylint version issue or what, but the previous way it was written I was getting mutually exclusive errors about indentation: CI required it to be one way, my local pylint required something else. This way they both agree is acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh no sorry, the pylint issue was somewhere else. This was just >80 chars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃
b91e8ab
to
5d9db92
Compare
How can you check the value of a cookie without changing the value? |
i landed here from SO question https://stackoverflow.com/a/48766639/4933053. how do i redirect within a callback, eg after some validation user should go from '/' to '/start' url. Can you please provide insighte, here or at SO. |
I have problem very similar to @hivemall, found the SO post that redirected to this issue indirectly. I don't see how this PR helps with the problem of redirection. Is it possible to get more details or a pointer to a page giving some explanations on how to implement a "login redirect" in a callback. Is it necessary to do this by talking to Falsk directly with an approach like suggested by https://community.plotly.com/t/how-protect-dash-routes-with-login-after-dash-1-0-release/25114/3? |
hi brother, I have the same issue to integrate my app with google auth. Do you solve the problem? |
@Tasselmi yes, I managed to implement the authentication using the approach suggested by https://community.plotly.com/t/how-protect-dash-routes-with-login-after-dash-1-0-release/25114/3 to trigger the authentication when accessing the page, using a In my case, for managing the authentication, I use the flask-mulitpass module that allows to manage several backends. But I'm pretty sure you can do this with simpler backends like |
Anyone landing here after this post, for the love of god, this isn't a help form. Don't post here. This is like, necroposting x10 |
Closes #182 using an alternative approach to #401 as mentioned in #401 (comment) - instead of making your own response object to return in place of the callback result, this PR makes a global object available that you can modify inside the callback (setting cookies or headers, for example)
I put this inside the
dash.callback_context
object, rather than making a newdash.callback_response
, mainly to take advantage of the nice protection @T4rk1n built in there against using these outside of the callback, or accidentally clobbering them.Per the example in the test, usage is like:
cc @jkseppan @plotly/dash-core