Commit graph

155 commits

Author SHA1 Message Date
Simon Willison
687907aa2b Remove python-baseconv dependency, refs #1733, closes #1734 2022-05-02 12:39:06 -07:00
Simon Willison
143c105f87 Removed rogue print 2022-04-12 11:43:32 -07:00
Simon Willison
90d1be9952 Tilde encoding now encodes space as plus, closes #1701
Refs #1657
2022-04-06 08:55:01 -07:00
Simon Willison
5c5e9b3657 Request.fake(... url_vars), plus .fake() is now documented
Also made 'from datasette import Request' shortcut work.

Closes #1697
2022-03-31 19:01:58 -07:00
Simon Willison
72bfd75fb7 Drop n=1 threshold down to <= 20ms, closes #1679 2022-03-21 14:55:50 -07:00
Simon Willison
1a7750eb29 Documented datasette.check_visibility() method, closes #1678 2022-03-21 12:01:37 -07:00
Simon Willison
798f075ef9 Read format from route captures, closes #1667
Refs #1660
2022-03-19 13:32:29 -07:00
Simon Willison
711767bcd3 Refactored URL routing to add tests, closes #1666
Refs #1660
2022-03-18 21:03:08 -07:00
Simon Willison
a35393b29c
Tilde encoding (#1659)
Closes #1657

Refs #1439
2022-03-15 11:01:57 -07:00
Simon Willison
77e718c3ff Revert "Fix bug with percentage redirects, close #1650"
This reverts commit c85d669de3.

Refs #1658
2022-03-15 08:37:31 -07:00
Simon Willison
c85d669de3 Fix bug with percentage redirects, close #1650 2022-03-07 11:26:08 -08:00
Simon Willison
1baa030eca
Switch to dash encoding for table/database/row-pk in paths
* Dash encoding functions, tests and docs, refs #1439
* dash encoding is now like percent encoding but with dashes
* Use dash-encoding for row PKs and ?_next=, refs #1439
* Use dash encoding for table names, refs #1439
* Use dash encoding for database names, too, refs #1439

See also https://simonwillison.net/2022/Mar/5/dash-encoding/
2022-03-07 07:38:29 -08:00
Dan Peterson
de810f49cc
Add /opt/homebrew to where spatialite extension can be found (#1649)
Helps homebrew on Apple Silicon setups find spatialite without needing
a full path.

Similar to #1114

Thanks, @danp
2022-03-06 11:39:15 -08:00
Simon Willison
458f03ad3a More SpatiaLite details on /-/versions, closes #1607 2022-02-08 22:32:19 -08:00
Simon Willison
d9b508ffaa @documented decorator plus unit test plus sphinx.ext.autodoc
New mechanism for marking datasette.utils functions that should be covered by the
documentation, then testing that they have indeed been documented.

Also enabled sphinx.ext.autodoc which can now be used to embed the documented
versions of those functions.

Refs #1176
2022-02-06 22:31:06 -08:00
Simon Willison
3ef47a0896 Link rel=alternate header for tables and rows
Also added Access-Control-Expose-Headers: Link to --cors mode.

Closes #1533

Refs https://github.com/simonw/datasette-notebook/issues/2

LL#	metadata.json.1
2022-02-01 23:49:09 -08:00
Simon Willison
63537dd3de Allow 'explain query plan' with more whitespace, closes #1588 2022-01-13 12:34:55 -08:00
Simon Willison
8c401ee0f0 Fixed remaining code and docs for new block=True default, closes #1579 2021-12-23 11:18:20 -08:00
Simon Willison
5fac26aa22 Another populate_schema_tables optimization, refs #1555 2021-12-19 12:54:12 -08:00
Simon Willison
97b1723dd0 Optimize init_internal_db by running PRAGMA in a single function
Refs #1555
2021-12-18 19:49:11 -08:00
Simon Willison
d637ed4676 Use execute_write_many to optimize internal DB, refs #1555, #1570 2021-12-18 11:11:08 -08:00
Simon Willison
5cadc24489 db.execute_write_script() and db.execute_write_many(), closes #1570
Refs #1555
2021-12-18 10:57:22 -08:00
Simon Willison
2e4ba71b53 Optimize create table calls using executescript=True
Refs #1555, #1569
2021-12-18 10:34:15 -08:00
Simon Willison
a6ff123de5 keep_blank_values=True when parsing query_string, closes #1551
Refs #1518
2021-12-12 12:01:51 -08:00
Simon Willison
ff0dd4da38 repr() method for Request, refs #1519 2021-11-19 12:29:37 -08:00
Simon Willison
8584993529 --cors Access-Control-Allow-Headers: Authorization
Refs #1467, refs https://github.com/simonw/datasette-auth-tokens/issues/4
2021-10-14 12:03:28 -07:00
Simon Willison
b267b57754
Upgrade to httpx 0.20
* Upgrade to httpx 0.20, closes #1488
* TestClient.post() should not default to following redirects
2021-10-14 11:03:44 -07:00
Simon Willison
0d5cc20aef Revert "asyncio_run helper to deal with a 3.10 warning, refs #1482"
This reverts commit 98dcabccbb.
2021-10-09 18:25:33 -07:00
Simon Willison
98dcabccbb asyncio_run helper to deal with a 3.10 warning, refs #1482 2021-10-08 17:32:11 -07:00
Simon Willison
b1fed48a95 derive_named_parameters falls back to regex on SQL error, refs #1421 2021-08-08 20:26:08 -07:00
Simon Willison
fc4846850f New way of deriving named parameters using explain, refs #1421 2021-08-08 20:21:13 -07:00
Simon Willison
c00f29affc
Fix for race condition in refresh_schemas(), closes #1231 2021-07-16 12:44:58 -07:00
Simon Willison
dd5ee8e668 Removed some unused imports
I found these with:

    flake8 datasette | grep unus
2021-07-15 23:26:12 -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
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
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
d1d06ace49 ?_trac=1 for CSV, plus ?_nofacets=1 when rendering CSV
Closes #1351, closes #1350
2021-06-01 08:49:50 -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
640ac7071b Better PRAGMA error message, closes #1185 2021-01-12 14:26:19 -08:00
Simon Willison
8e8fc5cee5 Applied Black 2021-01-11 13:34:38 -08:00
Simon Willison
649f48cd70 request.full_path property, closes #1184 2021-01-11 13:32:58 -08:00
Miroslav Šedivý
a882d67962
Modernize code to Python 3.6+ (#1158)
* Compact dict and set building
* Remove redundant parentheses
* Simplify chained conditions
* Change method name to lowercase
* Use triple double quotes for docstrings

Thanks, @eumiro!
2020-12-23 09:04:32 -08:00
Simon Willison
90eba4c3ca Prettier CREATE TABLE SQL for _internal 2020-12-22 15:55:43 -08:00
Simon Willison
270de6527b Foreign keys for _internal database
Refs #1099 - Datasette now uses compound foreign keys internally,
so it would be great to link them correctly.
2020-12-22 11:48:54 -08:00
Simon Willison
bc1f1e1ce8 Compound primary key for foreign_keys table in _internal 2020-12-22 11:04:29 -08:00
Simon Willison
810853c5f2 Use time.perf_counter() instead of time.time(), closes #1157 2020-12-21 13:49:14 -08:00
Simon Willison
dcdfb2c301 Rename _schemas to _internal, closes #1156 2020-12-21 11:48:06 -08:00
Simon Willison
ebc7aa287c In-memory _schemas database tracking schemas of attached tables, closes #1150 2020-12-18 14:34:05 -08:00
Abdussamet Koçak
705d1a1555
Fix startup error on windows (#1128)
Fixes https://github.com/simonw/datasette/issues/1094

This import isn't used at all, and causes error on startup on Windows.
2020-12-05 11:35:03 -08:00
Simon Willison
00185af74a Show pysqlite3 version on /-/versions, if installed - #1125 2020-12-03 14:08:50 -08:00