You will need to provide more context. "Instance" is a Bokeh models property, and is typically only used and useful as a class attribute, but it looks like you are trying to use it outside a class definition here? If not, and you are trying to define a dict of ColumnDataSources on an app class, you will need to use the Bokeh Dict property, instead of the standard python dict.
class StockApp(VBox):
sData = Dict(String, ColumnDataSource) # or whatever key property type you want
It has to be Bokeh properties "all the way through" so that the model can properly validate and serialize itself.
I'm trying to create an app on bokeh-server, where I need
to create a dict (or list) of ColumnDataSource instances. #Data sources
sData = dict()
for Id in Data:
sData[Id] = Instance(ColumnDataSource)
Then I'm trying to catch a selection event:
def setup_events(self):
super(my_app, self).setup_events()
for Id in self.Data:
if self.sData[Id]:
self.sData[Id].on_change('selected', self, 'selection_change')
But there is an error:
AttributeError: 'Instance' object has no attribute 'on_change'
Is it possible to trig events from dictionary of ColumnDataSource and what I'm doing wrong?