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
Enable custom response support for callback functions #183
Conversation
8d0dcdc
to
48ad00b
Compare
48ad00b
to
36f5b53
Compare
Yeah, I like this solution. An alternative way to solve #182 would be to implement a |
class DashResponse(Response): | ||
""" | ||
Flask Response extended with option to convert a regular response to | ||
valid Dash json-encoded |
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.
missing "component" here? How about:
Flask Response extended with option to convert a regular response to
valid Dash json-encoded component.
Return aDashResponse
object from a Dash callback in order to set
other properties of the response like headers or cookies
} | ||
self.set_data( | ||
json.dumps(response, cls=plotly.utils.PlotlyJSONEncoder) | ||
) |
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.
could we make this code a little bit more DRY by combining it in some way with these lines?
Lines 494 to 506 in b61f0d3
response = { | |
'response': { | |
'props': { | |
output.component_property: output_value | |
} | |
} | |
} | |
return flask.Response( | |
json.dumps(response, | |
cls=plotly.utils.PlotlyJSONEncoder), | |
mimetype='application/json' | |
) |
Looks good! In order for this to be merged, I'd like to see:
I think that a full integration test would be best suited here. Most of the integration tests are in the |
@chriddyp - unfortunately, now I have no time to do this, but I'm going to go back to this PR as soon as my current project will be finished |
Hey @oryba - I'm interested in this feature and I'm willing to work on it, so if you don't mind I could try to add the requested test and do the refactoring? |
Hey @jkseppan, sorry for the late answer. I don't mind, thanks for your help, glad to see someone has a chance to finalize this feature. |
…n-4.0.1 Bump y18n from 4.0.0 to 4.0.1
* - update sort_settings to use column_id * update tests with column_id * update doc
* - update sort_settings to use column_id * update tests with column_id * update doc
Bump y18n from 4.0.0 to 4.0.1
Based on issue #182 (Set a cookie from callback function).
With the following functionality callback function can return not only Dash components tree, but a customizable DashResponse with cookies, headers etc.