Commit graph

1,116 commits

Author SHA1 Message Date
Simon Willison
05a312caf3 Applied Black, refs #1368 2021-06-26 15:25:28 -07:00
Brandon Roberts
baf986c871
New get_metadata() plugin hook for dynamic metadata
The following hook is added:

    get_metadata(
      datasette=self, key=key, database=database, table=table,
      fallback=fallback
    )

This gets called when we're building our metdata for the rest
of the system to use. We merge whatever the plugins return
with any local metadata (from metadata.yml/yaml/json) allowing
for a live-editable dynamic Datasette.

As a security precation, local meta is *not* overwritable by
plugin hooks. The workflow for transitioning to live-meta would
be to load the plugin with the full metadata.yaml and save.
Then remove the parts of the metadata that you want to be able
to change from the file.

* Avoid race condition: don't mutate databases list

This avoids the nasty "RuntimeError: OrderedDict mutated during
iteration" error that randomly happens when a plugin adds a
new database to Datasette, using `add_database`. This change
makes the add and remove database functions more expensive, but
it prevents the random explosion race conditions that make for
confusing user experience when importing live databases.

Thanks, @brandonrobertz
2021-06-26 15:24:54 -07:00
Simon Willison
02b19c7a9a Removed rogue pdb=True, refs #1377 2021-06-23 15:50:48 -07:00
Simon Willison
b1fd24ac9f skip_csrf(datasette, scope) plugin hook, refs #1377 2021-06-23 15:40:09 -07:00
Simon Willison
4a3e8561ab Default 405 for POST, plus tests 2021-06-23 15:40:09 -07:00
Chris Amico
a6c55afe8c
Ensure db.path is a string before trying to insert into internal database (#1370)
Thanks, @eyeseast
2021-06-21 08:57:38 -07:00
Simon Willison
d23a267138 Make request available to menu plugin hooks, closes #1371 2021-06-09 21:45:24 -07:00
Simon Willison
03ec71193b Don't truncate list of columns on /db page, closes #1364 2021-06-06 15:07:45 -07:00
Simon Willison
030deb4b25 Try to handle intermittent FileNotFoundError in tests
Refs #1361
2021-06-05 16:02:03 -07:00
Simon Willison
8f311d6c1d Correctly escape output of ?_trace, refs #1360 2021-06-05 15:03:38 -07:00
Simon Willison
ff29dd55fa ?_trace=1 now depends on trace_debug setting, closes #1359 2021-06-05 13:18:37 -07:00
Simon Willison
a634121525
Make custom pages compatible with base_url setting
Closes #1238

- base_url no longer causes custom page routing to fail
- new route_path key in request.scope storing the path that was used for routing with the base_url prefix stripped
- TestClient used by tests now avoids accidentally double processing of the base_url prefix
2021-06-05 11:59:54 -07:00
Simon Willison
d5d387abfe Applied Black, refs #1305 2021-06-01 21:30:44 -07:00
Simon Willison
80d8b0eb41 Test demonstrating fixed #1305, refs #1306 2021-06-01 21:26:25 -07:00
Simon Willison
f40d1b99d6 Don't show '0 results' on error page, refs #619 2021-06-01 21:09:10 -07:00
Simon Willison
ea5b237800 Show error message on bad query, closes #619 2021-06-01 20:59:29 -07:00
Simon Willison
9552414e1f
Re-display user's query with an error message if an error occurs (#1346)
* Ignore _shape when returning errors
2021-06-01 20:46:20 -07:00
Simon Willison
0f1e47287c Fixed bug with detect_fts for table with single quote in name, closes #1257 2021-06-01 20:27:04 -07:00
Simon Willison
807de378d0 /-/databases and homepage maintain connection order, closes #1216 2021-06-01 20:10:15 -07:00
Simon Willison
0539bf0816 Don't execute facets/counts for _shape=array or object, closes #263 2021-06-01 19:53:00 -07:00
Simon Willison
a18e8641bc Don't reflect nofacet=1 and nocount=1 in BLOB URLs, refs #1353 2021-06-01 15:35:33 -07:00
Simon Willison
fd368d3b2c New _nocount=1 option, used to speed up CSVs - closes #1353 2021-06-01 09:12:32 -07:00
Simon Willison
8bde6c5461 Rename ?_nofacets=1 to ?_nofacet=1, refs #1353 2021-06-01 08:56:00 -07:00
Simon Willison
d1d06ace49 ?_trac=1 for CSV, plus ?_nofacets=1 when rendering CSV
Closes #1351, closes #1350
2021-06-01 08:49:50 -07:00
Simon Willison
c5ae1197a2 ?_nofacets=1 option, closes #1350 2021-05-30 22:39:14 -04:00
Simon Willison
f7d3e76fb3 Facets now execute ignoring ?_col and ?_nocol, fixes #1345 2021-05-30 22:31:14 -04:00
Simon Willison
4545120c92 Test and docs for ?_facet_size=max, refs #1337 2021-05-27 09:04:26 -07:00
Simon Willison
7e983fede6 ?_facet_size=max, ... now links to that, closes #1337
Refs #1332
2021-05-27 09:00:58 -07:00
Simon Willison
f1c29fd6a1
?_col=/?_nocol= to show/hide columns on the table page
Closes #615

* Cog icon for hiding columns
* Show all columns cog menu item
* Do not allow hide column on primary keys
* Allow both ?_col= and ?_nocol=
* De-duplicate if ?_col= passed multiple times
* 400 error if user tries to ?_nocol= a primary key
* Documentation for ?_col= and ?_nocol=
2021-05-26 21:17:43 -07:00
Simon Willison
2bd9d54b27 Fix Jinja warnings, closes #1338, refs #1331 2021-05-23 18:41:50 -07:00
Simon Willison
9789b94da4 ?_facet_size=100 parameter, closes #1332 2021-05-22 17:34:33 -07:00
Simon Willison
0a7621f96f
Use pytest-xdist to speed up tests (#1290)
* Run tests in CI using pytest-xdist
* Documentation for pytest-xdist

Closes #1289
2021-04-02 20:42:28 -07:00
Simon Willison
d579fcf4f7 Applied some fixes suggested by @withshubh in #1260 2021-03-28 17:20:55 -07:00
Simon Willison
6ad544df5e Fixed master -> main in a bunch of places, mainly docs 2021-03-23 09:19:41 -07:00
Konstantin Baikov
8e18c79431
Use context manager instead of plain open (#1211)
Context manager with open closes the files after usage.

When the object is already a pathlib.Path i used read_text
write_text functions

In some cases pathlib.Path.open were used in context manager,
it is basically the same as builtin open.

Thanks, Konstantin Baikov!
2021-03-11 08:15:49 -08:00
Simon Willison
7c87532acc New .add_memory_database() method, closes #1247 2021-02-28 20:02:18 -08:00
Simon Willison
47eb885cc2 JSON faceting now suggested even if column has blank strings, closes #1246 2021-02-28 19:44:04 -08:00
Simon Willison
cc6774cbaa Upgrade httpx and remove xfail from tests, refs #1005 2021-02-28 14:34:44 -08:00
Simon Willison
726f781c50 Fix for arraycontains bug, closes #1239 2021-02-22 16:22:47 -08:00
Simon Willison
6f41c8a2be
--crossdb option for joining across databases (#1232)
* Test for cross-database join, refs #283
* Warn if --crossdb used with more than 10 DBs, refs #283
* latest.datasette.io demo of --crossdb joins, refs #283
* Show attached databases on /_memory page, refs #283
* Documentation for cross-database queries, refs #283
2021-02-18 14:09:12 -08:00
Simon Willison
36a44bffbf Validation for --port, closes #1226 2021-02-18 10:05:27 -08:00
Simon Willison
9603d893b9 Tests for --ssl-keyfile and --ssl-certfile, refs #1221 2021-02-11 16:53:20 -08:00
Simon Willison
eda652cf6e
--ssl-keyfile and --ssl-certfile options to "datasette serve"
Closes #1221
2021-02-11 16:52:16 -08:00
Simon Willison
7a2ed9f8a1 Fixed bug with ?_sort= and ?_search=, closes #1214 2021-02-02 13:21:03 -08:00
Simon Willison
1600d2a3ec Renamed /:memory: to /_memory, with redirects - closes #1205 2021-01-28 14:48:56 -08:00
Simon Willison
a5ede3cdd4 Fixed bug loading database called 'test-database (1).sqlite'
Closes #1181.

Also now ensures that database URLs have special characters URL-quoted.
2021-01-24 21:13:05 -08:00
Simon Willison
07e1635615 All ?_ parameters now copied to hidden form fields, closes #1194 2021-01-24 19:10:10 -08:00
Simon Willison
c38c42948c extra_body_script module support, closes #1187 2021-01-13 18:14:33 -08:00
Simon Willison
fa0c3777b8 script type=module support, closes #1186 2021-01-13 17:50:52 -08:00
Simon Willison
640ac7071b Better PRAGMA error message, closes #1185 2021-01-12 14:26:19 -08:00