I tried writing a simple callback, but I don’t know the right syntax
def event_callback(attributes):
print(‘attributes={}’.format(attributes))
plot.js_on_event(events.SelectionGeometry, event_callback(attributes=['geometry', 'final']))
the output just says
attributes=['geometry', 'final']
When I use the print_event call, I get
ERROR:bokeh.server.protocol_handler:error handling message
message: Message ‘PULL-DOC-REQ’ (revision 1) content: {}
error: TypeError(“Object of type ‘function’ is not JSON serializable”,)
Traceback (most recent call last):
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/server/protocol_handler.py”, line 100, in handle
work = yield handler(message, connection)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/tornado/gen.py”, line 735, in run
value = future.result()
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/tornado/gen.py”, line 748, in run
yielded = self.gen.send(value)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/server/session.py”, line 70, in _needs_document_lock_wrapper
result = yield yield_for_all_futures(func(self, *args, **kwargs))
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/server/session.py”, line 228, in _handle_pull
return connection.protocol.create(‘PULL-DOC-REPLY’, message.header[‘msgid’], self.document)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/protocol/init.py”, line 80, in create
return self._messages[msgtype].create(*args, **kwargs)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/protocol/messages/pull_doc_reply.py”, line 83, in create
content = { ‘doc’ : document.to_json() }
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/document/document.py”, line 845, in to_json
doc_json = self.to_json_string()
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/document/document.py”, line 874, in to_json_string
return serialize_json(json, indent=indent)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/core/json_encoder.py”, line 160, in serialize_json
return json.dumps(obj, cls=BokehJSONEncoder, allow_nan=False, indent=indent, separators=separators, sort_keys=True, **kwargs)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/json/init.py”, line 238, in dumps
**kw).encode(obj)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/json/encoder.py”, line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/json/encoder.py”, line 257, in iterencode
return _iterencode(o, 0)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/core/json_encoder.py”, line 251, in default
return self.transform_python_types(obj)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/site-packages/bokeh/core/json_encoder.py”, line 218, in transform_python_types
return super(BokehJSONEncoder, self).default(obj)
File “/home/bruce/anaconda3/envs/bokeh/lib/python3.6/json/encoder.py”, line 180, in default
o.class.name)
TypeError: Object of type ‘function’ is not JSON serializable