Thanks again Matthias.
I’m not using Bokeh server - just the local JS client.
I can see that the output data source (“target.data”) is updated before the JS callback returns but this never makes it in the corresponding Python object. I’m concluding - probably obvious when you think about it - that when the Bokeh JS object is instantiated it uses the Python objects as sources for data but then is essentially disconnected from them - so updates to the JS model are not propagated back to their Python parents.
However, I’ve found a bit of a hacky workaround using IPython.notebook.kernel.execute to create or overwrite a variable in the Python user namespace. This seems to work but it feels like I’m tampering with fundamental laws of physics and it may possibly mess me up at some point.
Here’s an example:
on_color_change = CustomJS(args=dict(plot=circ, selector=dropdown, range_tool=range_tool,
out=out_source),
code="""
var out_max = `'max': ${range_tool.x_range.end}`;
var out_min = `'min': ${range_tool.x_range.start}`;
var out_col = `'color': ${selector.value}`;
var out_data = `foo={ ${out_max}, ${out_min}, ${out_col} }`;
console.log(out_data);
IPython.notebook.kernel.execute(out_data);
""")