mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Show error if --setting hash_urls 1 used, refs #1661
This commit is contained in:
parent
d4f60c2388
commit
8658c66438
3 changed files with 35 additions and 8 deletions
|
|
@ -118,11 +118,6 @@ SETTINGS = (
|
||||||
50,
|
50,
|
||||||
"Time limit for calculating a suggested facet",
|
"Time limit for calculating a suggested facet",
|
||||||
),
|
),
|
||||||
Setting(
|
|
||||||
"hash_urls",
|
|
||||||
False,
|
|
||||||
"Include DB file contents hash in URLs, for far-future caching",
|
|
||||||
),
|
|
||||||
Setting(
|
Setting(
|
||||||
"allow_facet",
|
"allow_facet",
|
||||||
True,
|
True,
|
||||||
|
|
@ -177,6 +172,16 @@ SETTINGS = (
|
||||||
),
|
),
|
||||||
Setting("base_url", "/", "Datasette URLs should use this base path"),
|
Setting("base_url", "/", "Datasette URLs should use this base path"),
|
||||||
)
|
)
|
||||||
|
OBSOLETE_SETTINGS = {
|
||||||
|
option.name: option
|
||||||
|
for option in (
|
||||||
|
Setting(
|
||||||
|
"hash_urls",
|
||||||
|
False,
|
||||||
|
"The hash_urls setting has been removed, try the datasette-hashed-urls plugin instead",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
DEFAULT_SETTINGS = {option.name: option.default for option in SETTINGS}
|
DEFAULT_SETTINGS = {option.name: option.default for option in SETTINGS}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,14 @@ from subprocess import call
|
||||||
import sys
|
import sys
|
||||||
from runpy import run_module
|
from runpy import run_module
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from .app import Datasette, DEFAULT_SETTINGS, SETTINGS, SQLITE_LIMIT_ATTACHED, pm
|
from .app import (
|
||||||
|
OBSOLETE_SETTINGS,
|
||||||
|
Datasette,
|
||||||
|
DEFAULT_SETTINGS,
|
||||||
|
SETTINGS,
|
||||||
|
SQLITE_LIMIT_ATTACHED,
|
||||||
|
pm,
|
||||||
|
)
|
||||||
from .utils import (
|
from .utils import (
|
||||||
StartupError,
|
StartupError,
|
||||||
check_connection,
|
check_connection,
|
||||||
|
|
@ -50,8 +57,12 @@ class Config(click.ParamType):
|
||||||
return
|
return
|
||||||
name, value = config.split(":", 1)
|
name, value = config.split(":", 1)
|
||||||
if name not in DEFAULT_SETTINGS:
|
if name not in DEFAULT_SETTINGS:
|
||||||
|
if name in OBSOLETE_SETTINGS:
|
||||||
|
msg = OBSOLETE_SETTINGS[name].help
|
||||||
|
else:
|
||||||
|
msg = f"{name} is not a valid option (--help-settings to see all)"
|
||||||
self.fail(
|
self.fail(
|
||||||
f"{name} is not a valid option (--help-settings to see all)",
|
msg,
|
||||||
param,
|
param,
|
||||||
ctx,
|
ctx,
|
||||||
)
|
)
|
||||||
|
|
@ -83,8 +94,12 @@ class Setting(CompositeParamType):
|
||||||
def convert(self, config, param, ctx):
|
def convert(self, config, param, ctx):
|
||||||
name, value = config
|
name, value = config
|
||||||
if name not in DEFAULT_SETTINGS:
|
if name not in DEFAULT_SETTINGS:
|
||||||
|
if name in OBSOLETE_SETTINGS:
|
||||||
|
msg = OBSOLETE_SETTINGS[name].help
|
||||||
|
else:
|
||||||
|
msg = f"{name} is not a valid option (--help-settings to see all)"
|
||||||
self.fail(
|
self.fail(
|
||||||
f"{name} is not a valid option (--help-settings to see all)",
|
msg,
|
||||||
param,
|
param,
|
||||||
ctx,
|
ctx,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -310,3 +310,10 @@ def test_help_settings():
|
||||||
result = runner.invoke(cli, ["--help-settings"])
|
result = runner.invoke(cli, ["--help-settings"])
|
||||||
for setting in SETTINGS:
|
for setting in SETTINGS:
|
||||||
assert setting.name in result.output
|
assert setting.name in result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_help_error_on_hash_urls_setting():
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(cli, ["--setting", "hash_urls", 1])
|
||||||
|
assert result.exit_code == 2
|
||||||
|
assert 'The hash_urls setting has been removed' in result.output
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue