Skip to content
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

Expose settings API to other handlers. #94

Merged
merged 1 commit into from
Jul 5, 2020

Conversation

goanpeca
Copy link
Member

@goanpeca goanpeca commented Jul 3, 2020

Hi @afshin, would something like this be ok so other handlers can access the settings in a friendlier fashion?

On the localization work, I use the current locale set by the user and based on that I provide the available language in original and localized form (for the current local)

Thoughts?

Copy link
Member

@afshin afshin left a comment

Choose a reason for hiding this comment

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

Cheers @goanpeca!

This is a good solution to how server side extensions access user settings.

@goanpeca
Copy link
Member Author

goanpeca commented Jul 3, 2020

Ok, let me add some tests then :-p

@afshin
Copy link
Member

afshin commented Jul 3, 2020

Is it possible to combine _get_settings and get_settings so that the handler uses the same exact logic? It might prevent an out of sync bug in the future.

@goanpeca
Copy link
Member Author

goanpeca commented Jul 3, 2020

Is it possible to combine _get_settings and get_settings so that the handler uses the same exact logic? It might prevent an out of sync bug in the future.

Yeah I think so. Will update the code.

@goanpeca
Copy link
Member Author

goanpeca commented Jul 4, 2020

Is it possible to combine _get_settings and get_settings so that the handler uses the same exact logic? It might prevent an out of sync bug in the future.

@afshin I did something else, get_settings is now used inside the get handler and also as the API exposed to other handlers so now the handler and the API use the same get_settings (public) method. The private _get_settings, well is private and has a different signature so no risk getting out of sync now.

Since now the get method is using the same thing as the API (public method) I think the current tests are covering the use cases.

@goanpeca goanpeca closed this Jul 4, 2020
@goanpeca goanpeca reopened this Jul 4, 2020
@goanpeca goanpeca force-pushed the enh/expose-settings-api branch 3 times, most recently from a7a4c05 to 393694b Compare July 4, 2020 22:51
path = _path(settings_dir, schema_name, False, SETTINGS_EXTENSION)
raw = '{}'
settings = dict()
settings = {}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is faster to use than dict, so .. why not use it 🙃

@goanpeca goanpeca force-pushed the enh/expose-settings-api branch 3 times, most recently from 4ee5ef2 to d99ea9f Compare July 4, 2020 23:02
@afshin afshin changed the title PR: Expose settings API to other handlers. Expose settings API to other handlers. Jul 5, 2020
@blink1073 blink1073 merged commit 579c623 into jupyterlab:master Jul 5, 2020
@blink1073
Copy link
Contributor

Published as 1.2.0, JupyterLab will need an update: https://github.com/jupyterlab/jupyterlab/blob/master/setup.py#L154

@goanpeca goanpeca deleted the enh/expose-settings-api branch July 5, 2020 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants