mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Renamed datasette.config() to .setting(), closes #1107
This commit is contained in:
parent
5a77f7a649
commit
f2e2bfcdd9
10 changed files with 86 additions and 60 deletions
|
|
@ -230,7 +230,7 @@ class DataView(BaseView):
|
|||
should_redirect += kwargs["as_db"]
|
||||
|
||||
if (
|
||||
(self.ds.config("hash_urls") or "_hash" in request.args)
|
||||
(self.ds.setting("hash_urls") or "_hash" in request.args)
|
||||
and
|
||||
# Redirect only if database is immutable
|
||||
not self.ds.databases[name].is_mutable
|
||||
|
|
@ -260,7 +260,7 @@ class DataView(BaseView):
|
|||
stream = request.args.get("_stream")
|
||||
if stream:
|
||||
# Some quick sanity checks
|
||||
if not self.ds.config("allow_csv_stream"):
|
||||
if not self.ds.setting("allow_csv_stream"):
|
||||
raise BadRequest("CSV streaming is disabled")
|
||||
if request.args.get("_next"):
|
||||
raise BadRequest("_next not allowed for CSV streaming")
|
||||
|
|
@ -296,7 +296,7 @@ class DataView(BaseView):
|
|||
|
||||
async def stream_fn(r):
|
||||
nonlocal data
|
||||
writer = csv.writer(LimitedWriter(r, self.ds.config("max_csv_mb")))
|
||||
writer = csv.writer(LimitedWriter(r, self.ds.setting("max_csv_mb")))
|
||||
first = True
|
||||
next = None
|
||||
while first or (next and stream):
|
||||
|
|
@ -566,9 +566,9 @@ class DataView(BaseView):
|
|||
ttl = request.args.get("_ttl", None)
|
||||
if ttl is None or not ttl.isdigit():
|
||||
if correct_hash_provided:
|
||||
ttl = self.ds.config("default_cache_ttl_hashed")
|
||||
ttl = self.ds.setting("default_cache_ttl_hashed")
|
||||
else:
|
||||
ttl = self.ds.config("default_cache_ttl")
|
||||
ttl = self.ds.setting("default_cache_ttl")
|
||||
|
||||
return self.set_response_headers(r, ttl)
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ class DatabaseView(DataView):
|
|||
"show_hidden": request.args.get("_show_hidden"),
|
||||
"editable": True,
|
||||
"metadata": metadata,
|
||||
"allow_download": self.ds.config("allow_download")
|
||||
"allow_download": self.ds.setting("allow_download")
|
||||
and not db.is_mutable
|
||||
and database != ":memory:",
|
||||
},
|
||||
|
|
@ -161,7 +161,7 @@ class DatabaseDownload(DataView):
|
|||
db = self.ds.databases[database]
|
||||
if db.is_memory:
|
||||
raise DatasetteError("Cannot download :memory: database", status=404)
|
||||
if not self.ds.config("allow_download") or db.is_mutable:
|
||||
if not self.ds.setting("allow_download") or db.is_mutable:
|
||||
raise Forbidden("Database download is forbidden")
|
||||
if not db.path:
|
||||
raise DatasetteError("Cannot download database", status=404)
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ class RowTableShared(DataView):
|
|||
}
|
||||
|
||||
cell_rows = []
|
||||
base_url = self.ds.config("base_url")
|
||||
base_url = self.ds.setting("base_url")
|
||||
for row in rows:
|
||||
cells = []
|
||||
# Unless we are a view, the first column is a link - either to the rowid
|
||||
|
|
@ -654,7 +654,7 @@ class TableView(RowTableShared):
|
|||
pass
|
||||
|
||||
# facets support
|
||||
if not self.ds.config("allow_facet") and any(
|
||||
if not self.ds.setting("allow_facet") and any(
|
||||
arg.startswith("_facet") for arg in request.args
|
||||
):
|
||||
raise BadRequest("_facet= is not allowed")
|
||||
|
|
@ -772,8 +772,8 @@ class TableView(RowTableShared):
|
|||
suggested_facets = []
|
||||
|
||||
if (
|
||||
self.ds.config("suggest_facets")
|
||||
and self.ds.config("allow_facet")
|
||||
self.ds.setting("suggest_facets")
|
||||
and self.ds.setting("allow_facet")
|
||||
and not _next
|
||||
):
|
||||
for facet in facet_instances:
|
||||
|
|
@ -801,7 +801,7 @@ class TableView(RowTableShared):
|
|||
results.description,
|
||||
rows,
|
||||
link_column=not is_view,
|
||||
truncate_cells=self.ds.config("truncate_cells_html"),
|
||||
truncate_cells=self.ds.setting("truncate_cells_html"),
|
||||
)
|
||||
metadata = (
|
||||
(self.ds.metadata("databases") or {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue