Skip to content

Commit cbe3b92

Browse files
authored
Revert "Delay list -> dict conversation to end (#192)" (#234)
This reverts commit 7b9c024.
1 parent cce8b4e commit cbe3b92

File tree

4 files changed

+8
-38
lines changed

4 files changed

+8
-38
lines changed

jupyterlab_server/config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_page_config(labextensions_path, app_settings_dir=None, logger=None):
9797
# Convert lists to dicts
9898
for key in [disabled_key, "deferredExtensions"]:
9999
if key in data:
100-
data[key] = dict((k, True) for k in data[key])
100+
data[key] = dict((key, True) for key in data[key])
101101

102102
recursive_update(page_config, data)
103103

@@ -167,6 +167,12 @@ def get_page_config(labextensions_path, app_settings_dir=None, logger=None):
167167
rollup_disabled.update(page_config.get(disabled_key, []))
168168
page_config[disabled_key] = rollup_disabled
169169

170+
# Convert dictionaries to lists to give to the front end
171+
for (key, value) in page_config.items():
172+
173+
if isinstance(value, dict):
174+
page_config[key] = [subkey for subkey in value if value[subkey]]
175+
170176
return page_config
171177

172178

jupyterlab_server/handlers.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Module globals
2626
# -----------------------------------------------------------------------------
2727

28-
MASTER_URL_PATTERN = r'/(?P<mode>{}|doc)(?P<workspace>/workspaces/[a-zA-Z0-9\-\_]+)?(?P<tree>/tree/.*)?'
28+
MASTER_URL_PATTERN = '/(?P<mode>{}|doc)(?P<workspace>/workspaces/[a-zA-Z0-9\-\_]+)?(?P<tree>/tree/.*)?'
2929

3030
DEFAULT_TEMPLATE = template.Template("""
3131
<!DOCTYPE html>
@@ -127,13 +127,6 @@ def get_page_config(self):
127127
if page_config_hook:
128128
page_config = page_config_hook(self, page_config)
129129

130-
# Convert dictionaries to lists to give to the front end
131-
# copy first, so that we don't have converted values in page_copy that we have a ref to
132-
page_config = page_config.copy()
133-
for (key, value) in page_config.items():
134-
if isinstance(value, dict):
135-
page_config[key] = [subkey for subkey in value if value[subkey]]
136-
137130
return page_config
138131

139132
@web.authenticated

jupyterlab_server/pytest_plugin.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,6 @@ def _make_labserver_extension_app(**kwargs):
112112
data = dict(name=target_name, jupyterlab=dict(extension=True))
113113
json.dump(data, fid)
114114

115-
# Disable an extension in page config
116-
app_page_config = pjoin(app_settings_dir, 'page_config.json')
117-
with open(app_page_config, mode="w", encoding='utf-8') as fid:
118-
json.dump({
119-
"disabledExtensions": {
120-
"@foo/bar:plugin": True
121-
}
122-
}, fid)
123-
124115
# Copy the overrides file.
125116
src = pjoin(
126117
os.path.abspath(os.path.dirname(__file__)),

jupyterlab_server/tests/test_labapp.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""Basic tests for the lab handlers.
22
"""
33

4-
import json
54
import pytest
6-
import re
75
import tornado
86

97
from .utils import expected_http_error
@@ -30,24 +28,6 @@ async def test_lab_handler(notebooks, jp_fetch):
3028
assert "JupyterLab Server Application" in html
3129

3230

33-
async def test_page_config(labserverapp, jp_fetch):
34-
settings = labserverapp.serverapp.web_app.settings
35-
page_config = settings.setdefault('page_config_data', {})
36-
# In labserverapp fixture, we dump a page_config file that also disables "@foo/bar:plugin"
37-
# Here we check that we correctly merge those settings with page_config_data in settings
38-
page_config.setdefault("disabledExtensions", {"@acme/paint:plugin": True})
39-
r = await jp_fetch('lab', 'jlab_test_notebooks')
40-
assert r.code == 200
41-
# Check that the lab template is loaded
42-
html = r.body.decode()
43-
m = re.search(
44-
r'<script id="jupyter-config-data" type="application/json">(?P<page_config>.*?)</script>',
45-
html,
46-
re.MULTILINE | re.DOTALL
47-
)
48-
page_config = json.loads(m.group("page_config"))
49-
assert sorted(page_config['disabledExtensions']) == ["@acme/paint:plugin", "@foo/bar:plugin"]
50-
5131
async def test_notebook_handler(notebooks, jp_fetch):
5232
for nbpath in notebooks:
5333
r = await jp_fetch('lab', nbpath)

0 commit comments

Comments
 (0)