Also remove default_cache_ttl_hashed setting, refs #1661

This commit is contained in:
Simon Willison 2022-03-18 17:25:14 -07:00
commit 9979dcd07f
5 changed files with 16 additions and 35 deletions

View file

@ -134,11 +134,6 @@ SETTINGS = (
5,
"Default HTTP cache TTL (used in Cache-Control: max-age= header)",
),
Setting(
"default_cache_ttl_hashed",
365 * 24 * 60 * 60,
"Default HTTP cache TTL for hashed URL pages",
),
Setting("cache_size_kb", 0, "SQLite cache size in KB (0 == use SQLite default)"),
Setting(
"allow_csv_stream",
@ -172,17 +167,11 @@ SETTINGS = (
),
Setting("base_url", "/", "Datasette URLs should use this base path"),
)
_HASH_URLS_REMOVED = "The hash_urls setting has been removed, try the datasette-hashed-urls plugin instead"
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",
),
)
"hash_urls": _HASH_URLS_REMOVED,
"default_cache_ttl_hashed": _HASH_URLS_REMOVED,
}
DEFAULT_SETTINGS = {option.name: option.default for option in SETTINGS}
FAVICON_PATH = app_root / "datasette" / "static" / "favicon.png"

View file

@ -57,10 +57,10 @@ class Config(click.ParamType):
return
name, value = config.split(":", 1)
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)"
msg = (
OBSOLETE_SETTINGS.get(name)
or f"{name} is not a valid option (--help-settings to see all)"
)
self.fail(
msg,
param,
@ -94,10 +94,10 @@ class Setting(CompositeParamType):
def convert(self, config, param, ctx):
name, value = config
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)"
msg = (
OBSOLETE_SETTINGS.get(name)
or f"{name} is not a valid option (--help-settings to see all)"
)
self.fail(
msg,
param,

View file

@ -28,14 +28,7 @@ class Urls:
return self.path("-/logout")
def database(self, database, format=None):
db = self.ds.databases[database]
if self.ds.setting("hash_urls") and db.hash:
path = self.path(
f"{tilde_encode(database)}-{db.hash[:HASH_LENGTH]}", format=format
)
else:
path = self.path(tilde_encode(database), format=format)
return path
return self.path(tilde_encode(database), format=format)
def table(self, database, table, format=None):
path = f"{self.database(database)}/{tilde_encode(table)}"