From 6ef4903a3327fd245907d392148ab39886bb59d9 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Wed, 26 Apr 2017 17:15:50 -0400 Subject: [PATCH] Change 'module' to refer to an abstract specification version. --- ipywidgets/widgets/tests/test_interaction.py | 2 +- ipywidgets/widgets/widget.py | 23 ++++++++++---------- ipywidgets/widgets/widget_core.py | 2 ++ ipywidgets/widgets/widget_link.py | 2 -- jupyter-js-widgets/src/widget_core.ts | 14 ++++++------ 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/ipywidgets/widgets/tests/test_interaction.py b/ipywidgets/widgets/tests/test_interaction.py index 765ee1c3930..754ab8a0be7 100644 --- a/ipywidgets/widgets/tests/test_interaction.py +++ b/ipywidgets/widgets/tests/test_interaction.py @@ -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 diff --git a/ipywidgets/widgets/widget.py b/ipywidgets/widgets/widget.py index b26b9b3bfe5..a506300f1b5 100644 --- a/ipywidgets/widgets/widget.py +++ b/ipywidgets/widgets/widget.py @@ -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): @@ -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) diff --git a/ipywidgets/widgets/widget_core.py b/ipywidgets/widgets/widget_core.py index 791b9c3bab2..8737eb7bcb8 100644 --- a/ipywidgets/widgets/widget_core.py +++ b/ipywidgets/widgets/widget_core.py @@ -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) diff --git a/ipywidgets/widgets/widget_link.py b/ipywidgets/widgets/widget_link.py index 6101a36f1a5..9246a1bf27a 100644 --- a/ipywidgets/widgets/widget_link.py +++ b/ipywidgets/widgets/widget_link.py @@ -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) diff --git a/jupyter-js-widgets/src/widget_core.ts b/jupyter-js-widgets/src/widget_core.ts index 97ab4c43388..9baf3ce482e 100644 --- a/jupyter-js-widgets/src/widget_core.ts +++ b/jupyter-js-widgets/src/widget_core.ts @@ -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 }); } } @@ -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 }); } } @@ -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 }); } }