Skip to content

Remove workaround for comm_info message #175

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

Merged
merged 1 commit into from
Dec 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions ipywidgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,3 @@ def _handle_ipython():
load_ipython_extension(ip)

_handle_ipython()


# Workaround for the absence of a comm_info_[request/reply] shell message
class CommInfo(Widget):
"""CommInfo widgets are is typically instantiated by the front-end.

As soon as it is instantiated, it sends the collection of valid comms, and
kills itself. It is a workaround to the absence of comm_info shell
message.
"""

def __init__(self, **kwargs):
super(CommInfo, self).__init__(**kwargs)
target_name = 'ipython.widget'
comms = {
k: dict(target_name=v.target_name)
for (k, v) in self.comm.kernel.comm_manager.comms.items()
if v is not self.comm and (v.target_name == target_name or target_name is None)
}
self.send(dict(comms=comms))
self.close()
23 changes: 3 additions & 20 deletions ipywidgets/static/widgets/js/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,30 +266,13 @@ define([

WidgetManager.prototype._get_comm_info = function() {
/**
* Gets a promise for the open comms in the backend
* Gets a promise for the valid widget models.
*/

// Version using the comm_list_[request/reply] shell message.
/*var that = this;
return new Promise(function(resolve, reject) {
kernel.comm_info(function(msg) {
resolve(msg['content']['comms']);
});
});*/

// Workaround for absence of comm_list_[request/reply] shell message.
// Create a new widget that gives the comm list and commits suicide.
var that = this;
return this._get_connected_kernel().then(function(kernel) {
return new Promise(function(resolve, reject) {
var comm = kernel.comm_manager.new_comm('ipython.widget',
{'widget_class': 'ipywidgets.CommInfo'},
'comm_info');
comm.on_msg(function(msg) {
var data = msg.content.data;
if (data.content && data.method === 'custom') {
resolve(data.content.comms);
}
kernel.comm_info('ipython.widget', function(msg) {
resolve(msg['content']['comms']);
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ def run(self):

setuptools_args = {}
install_requires = setuptools_args['install_requires'] = [
'ipython>=4.0.0dev0',
'ipykernel',
'ipython>=4.0.0',
'ipykernel>=4.2.0',
'traitlets',
'notebook',
'notebook>=4.1.0b1',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My python packaging knowledge to too weak -- will we have to change this when 4.1.0 final is released?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. If you look just above, we had ipython>=4.0.0dev0 for a long time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet

]

extras_require = setuptools_args['extras_require'] = {
Expand Down