Skip to content

Commit

Permalink
Change 'module' to refer to an abstract specification version.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Apr 26, 2017
1 parent b4120ec commit 3fde6d2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ipywidgets/widgets/tests/test_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ def test_get_interact_value():
from ipywidgets.widgets import ValueWidget
from traitlets import Unicode
class TheAnswer(ValueWidget):
_model_module = Unicode('jupyter-js-widgets')
_model_name = Unicode('TheAnswer')
description = Unicode()
def get_interact_value(self):
return 42
Expand Down
23 changes: 12 additions & 11 deletions ipywidgets/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from base64 import standard_b64decode, standard_b64encode

from .._version import __protocol_version__
from .._version import __protocol_version__, __jupyter_widget_version__


def _widget_to_json(x, obj):
Expand Down Expand Up @@ -316,18 +316,19 @@ def get_view_spec(self):
#-------------------------------------------------------------------------
# Traits
#-------------------------------------------------------------------------
_model_module = Unicode(None,
help="A JavaScript module name in which to find _model_name.", read_only=True).tag(sync=True)
_model_name = Unicode('WidgetModel',
help="Name of the model.", read_only=True).tag(sync=True)
_model_module_version = Unicode('*',
help="A semver requirement for the model module version.", read_only=True).tag(sync=True)
_view_module = Unicode(None, allow_none=True,
help="A JavaScript module in which to find _view_name.").tag(sync=True)
_view_name = Unicode(None, allow_none=True,
help="Name of the view object.").tag(sync=True)
_view_module_version = Unicode('*',
help="A semver requirement for the view module.").tag(sync=True)
_model_module = Unicode('jupyter-js-widgets',
help="The namespace for the model.", read_only=True).tag(sync=True)
_model_module_version = Unicode(__jupyter_widget_version__,
help="A semver requirement for namespace version containing the model.", read_only=True).tag(sync=True)
_view_name = Unicode('',
help="Name of the view.").tag(sync=True)
_view_module = Unicode('',
help="The namespace for the view.").tag(sync=True)
_view_module_version = Unicode('',
help="A semver requirement for the namespace version containing the view.").tag(sync=True)

_view_count = Int(read_only=True,
help="EXPERIMENTAL: The number of views of the model displayed in the frontend. This attribute is experimental and may change or be removed in the future.").tag(sync=True)
comm = Instance('ipykernel.comm.Comm', allow_none=True)
Expand Down
2 changes: 2 additions & 0 deletions ipywidgets/widgets/widget_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@

class CoreWidget(Widget):

_model_module = Unicode('jupyter-js-widgets').tag(sync=True)
_model_module_version = Unicode(__jupyter_widget_version__).tag(sync=True)
_view_module = Unicode('jupyter-js-widgets').tag(sync=True)
_view_module_version = Unicode(__jupyter_widget_version__).tag(sync=True)
2 changes: 0 additions & 2 deletions ipywidgets/widgets/widget_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class Link(CoreWidget):
target: a (Widget, 'trait_name') tuple that should be updated
"""

_model_module = Unicode('jupyter-js-widgets').tag(sync=True)
_view_module = Unicode('jupyter-js-widgets').tag(sync=True)
_model_name = Unicode('LinkModel').tag(sync=True)
target = WidgetTraitTuple(help="The target (widget, 'trait_name') pair").tag(sync=True, **widget_serialization)
source = WidgetTraitTuple(help="The source (widget, 'trait_name') pair").tag(sync=True, **widget_serialization)
Expand Down
14 changes: 7 additions & 7 deletions jupyter-js-widgets/src/widget_core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {

import * as _ from 'underscore';

var semver_range = '^' + require('../package.json').version;
let jupyterWidgetSpecVersion = '3';

export
class CoreWidgetModel extends WidgetModel {
defaults() {
return _.extend(super.defaults(), {
_model_name: 'CoreWidgetModel',
_model_module_version: semver_range,
_view_module_version: semver_range
_model_module_version: jupyterWidgetSpecVersion,
_view_module_version: jupyterWidgetSpecVersion
});
}
}
Expand All @@ -28,8 +28,8 @@ class CoreDOMWidgetModel extends DOMWidgetModel {
defaults() {
return _.extend(super.defaults(), {
_model_name: 'CoreDOMWidgetModel',
_model_module_version: semver_range,
_view_module_version: semver_range
_model_module_version: jupyterWidgetSpecVersion,
_view_module_version: jupyterWidgetSpecVersion
});
}
}
Expand All @@ -39,8 +39,8 @@ class CoreLabeledDOMWidgetModel extends LabeledDOMWidgetModel {
defaults() {
return _.extend(super.defaults(), {
_model_name: 'CoreLabeledDOMWidgetModel',
_model_module_version: semver_range,
_view_module_version: semver_range
_model_module_version: jupyterWidgetSpecVersion,
_view_module_version: jupyterWidgetSpecVersion
});
}
}

0 comments on commit 3fde6d2

Please sign in to comment.