Wykres commitów

692 Commity (da0b3ce2b76227f1cd0cfdd3df361712c17ddcd0)

Autor SHA1 Wiadomość Data
Simon Willison da0b3ce2b7 New run_sanity_checks mechanism, for SpatiLite
Moved VirtualSpatialIndex check into a new mechanism that should allow
us to add further sanity checks in the future.

To test this I've had to commit a binary sample SpatiaLite database to
the repository. I included a build script for creating that database.

Closes #466
2019-05-11 15:55:30 -07:00
Simon Willison c692cd2911 Fix test ordering 2019-05-11 15:03:52 -07:00
Simon Willison a187c81e0c Black + fix broken test 2019-05-11 14:45:59 -07:00
Simon Willison c0d1b4c322 "datasette inspect foo.db" now just calculates table counts
Refs #462

* inspect command now just outputs table counts
* test_inspect.py is now only tests for that CLI command
* Updated some relevant documentation
* Removed docs for /-/inspect since that is about to change
2019-05-11 14:36:57 -07:00
Simon Willison ce09e5d2d3 Fixed tests relating to #459 2019-05-11 13:58:22 -07:00
Simon Willison 05cabaebd9 Pass --token to now alias, refs #459 2019-05-11 13:35:34 -07:00
Simon Willison 09ef305c68 Fixed "datasette publish now ... --alias=x"
The --alias argument can now be passed more than once.

Also updated our Travis configuration to use this.

Fixes #459
2019-05-11 13:20:36 -07:00
Simon Willison a0d444837f Finished implementation of ?_trace=1 debug tool
I redesigned the JSON output and added a handy "traceback" key showing
three relevant lines of the current traceback for each logged query.

Closes #435
2019-05-11 12:06:22 -07:00
Simon Willison 37adf32290 Changelog for 0.27.1 2019-05-11 11:34:13 -07:00
Simon Willison e7b31ae8c1
Use now --target production instead of now alias
Fix for this error:

    $ now alias --token=$NOW_TOKEN
    > WARN! The `now alias` command (no arguments) was deprecated in favour of `now --target production`.
    > Error! Couldn't find a deployment to alias. Please provide one as an argument.
    The command "now alias --token=$NOW_TOKEN" exited with 1.

https://travis-ci.org/simonw/datasette/jobs/530597261
2019-05-11 10:06:23 -07:00
Simon Willison de005b9b7d Fixed 500 error on homepage 2019-05-09 22:28:16 -07:00
Simon Willison ad789eaaea Added some things to .gitignore 2019-05-09 22:28:16 -07:00
Veit Heller 9f8d9fe262 setup: add tests to package exclusion (#458) 2019-05-09 18:54:50 -07:00
Simon Willison f825e20121 Run black and update docs for #457 2019-05-09 09:48:13 -07:00
Simon Willison b80b03ac9a datasette publish cloudrun --service=x, closes #457 2019-05-09 09:45:01 -07:00
Simon Willison 2db977d8f3 tests/fixtures.py can now write out plugins too
This command:

    python tests/fixtures.py \
        fixtures.db \
        metadata.json \
        fixtures-plugins/

Will now create the fixtures.db and metadata.json files, AND create
a folder called fixtures-plugins/ containing two test plugins.

You can then run it like this:

    datasette fixtures.db \
        -m metadata.json --plugins-dir=fixtures-plugins/
2019-05-09 09:44:21 -07:00
Simon Willison 9fdb47ca95 New encode/decode_path_component functions
ASGI cannot differentiate between / and %2F in a URL, so we need an
alternative scheme for encoding the names of tables that contain special
characters such as /

For background, see
    https://github.com/django/asgiref/issues/51#issuecomment-450603464

Some examples:

    "table/and/slashes" => "tableU+002FandU+002Fslashes"
    "~table" => "U+007Etable"
    "+bobcats!" => "U+002Bbobcats!"
    "U+007Etable" => "UU+002B007Etable"
2019-05-09 09:44:21 -07:00
Simon Willison bfa2ae0d16
Promote Glitch instead of Datasette Publish
Datasette Publish is currently broken due to Zeit API and platform changes.
2019-05-08 17:02:47 -07:00
Simon Willison ec2db345e9 Fixed crash on /:memory: page 2019-05-05 14:01:14 -04:00
Simon Willison 9617e92aa8 Removed pointless return variable
handle_request() always returns None anyway.
2019-05-05 13:58:35 -04:00
Simon Willison 831515b834 Respect --cors for error pages, closes #453 2019-05-05 08:12:03 -04:00
Simon Willison 55643430f7
Added Code style: black badge 2019-05-03 22:21:21 -04:00
Simon Willison 35d6ee2790
Apply black to everything, enforce via unit tests (#449)
I've run the black code formatting tool against everything:

    black tests datasette setup.py

I also added a new unit test, in tests/test_black.py, which will fail if the code does not
conform to black's exacting standards.

This unit test only runs on Python 3.6 or higher, because black itself doesn't run on 3.5.
2019-05-03 22:15:14 -04:00
Jaap Roes 66c87cee0c Mark codemirror files as vendored (#367)
This should stop GitHub from incorrectly stating that Datasette is 46% JavaScript.
2019-05-03 17:11:19 -04:00
Simon Willison 93c65d29ba Fixed 500 error on /-/metadata page 2019-05-03 16:42:59 -04:00
Jaap Roes f853d5592e "python3 -m pip" is clearer (thanks @jaap3) (#368) 2019-05-03 14:18:42 -04:00
Simon Willison 553314dcd6
Use dist: xenial and python: 3.7 on Travis (#447) 2019-05-03 14:16:52 -04:00
Simon Willison 01b3de5b66 Unit test for binary data display, refs #442 2019-05-03 12:45:06 -04:00
Russ Garrett d555baf508 Suppress rendering of binary data - thanks @russss (#442)
Binary columns (including spatialite geographies) get shown as ugly
binary strings in the HTML by default. Nobody wants to see that mess.

Show the size of the column in bytes instead. If you want to decode
the binary data, you can use a plugin to do it.
2019-05-03 12:44:48 -04:00
Simon Willison bade9daeb2 Docs for 'datasette publish cloudrun', refs #434 2019-05-03 12:16:58 -04:00
Romain Primet 75a21fc2a1 datasette publish cloudrun (#434) - thanks, @rprimet
New publish subcommand that publishes using the
new Google Cloud Run platform.

    datasette publish cloudrun database.db
2019-05-03 09:59:01 -04:00
Russ Garrett bf229c9bd8 Pass view_name to extra_body_script hook (#443)
At the moment it's not easy to tell whether the hook is being called
in (for example) the row or table view, as in both cases the
`database` and `table` parameters are provided.

This passes the `view_name` added in #441 to the `extra_body_script`
hook.
2019-05-03 09:12:19 -04:00
Russ Garrett 470cf0b05d Add a max-line-length setting for flake8 (#444)
This stops my automatic editor linting from flagging lines which are too
long. It's been lingering in my checkout for ages.

160 is an arbitrary large number - we could alter it if we have any
opinions (but I find the line length limit to be my least favourite part
of PEP8).
2019-05-03 09:11:27 -04:00
Simon Willison 53d2f00b73 Implemented ArrayFacet, closes #359 2019-05-02 20:21:27 -04:00
Simon Willison ea66c45df9
Extract facet code out into a new plugin hook, closes #427 (#445)
Datasette previously only supported one type of faceting: exact column value counting.

With this change, faceting logic is extracted out into one or more separate classes which can implement other patterns of faceting - this is discussed in #427, but potential upcoming facet types include facet-by-date, facet-by-JSON-array, facet-by-many-2-many and more.

A new plugin hook, register_facet_classes, can be used by plugins to add in additional facet classes.

Each class must implement two methods: suggest(), which scans columns in the table to decide if they might be worth suggesting for faceting, and facet_results(), which executes the facet operation and returns results ready to be displayed in the UI.
2019-05-02 17:11:26 -07:00
Simon Willison efc93b8ab5 Entirely removed table_rows_count table property
We were not displaying this anywhere, and it is now expensive to calculate.

Refs #419, #420
2019-05-01 22:29:47 -07:00
Simon Willison 3651eedf20 Show 'many rows' if count times out, refs #420 2019-05-01 22:20:24 -07:00
Simon Willison ad9de774f7 Added missing file, refs #438 2019-05-01 22:10:23 -07:00
Simon Willison f553a67021 Don't load setuptools plugins during test runs
Uses pattern from https://docs.pytest.org/en/latest/example/simple.html#detect-if-running-from-within-a-pytest-run

Closes #438
2019-05-01 22:09:03 -07:00
Simon Willison 033cf0bcbb DatabaseView no longer uses .inspect(), closes #420 2019-05-01 18:13:26 -07:00
Simon Willison 50d2d1aac9 Fixed bug where metadata.json hidden tables were ignored 2019-05-01 17:54:48 -07:00
Simon Willison e7151ccccf Index page no longer uses inspect data - refs #420
Also introduced a mechanism whereby table counts are calculated against a time limit
but immutable databases have their table counts calculated on server startup.
2019-05-01 17:39:39 -07:00
Simon Willison 669fa21a71 Include request duration in traces 2019-05-01 16:27:14 -07:00
Russ Garrett cf406c0754 New plugin hook: register_output_renderer hook (#441)
Thanks @russss!

* Add register_output_renderer hook

This changeset refactors out the JSON renderer and then adds a hook and
dispatcher system to allow custom output renderers to be registered.

The CSV output renderer is untouched because supporting streaming
renderers through this system would be significantly more complex, and
probably not worthwhile.

We can't simply allow hooks to be called at request time because we need
a list of supported file extensions when the request is being routed in
order to resolve ambiguous database/table names. So, renderers need to
be registered at startup.

I've tried to make this API independent of Sanic's request/response
objects so that this can remain stable during the switch to ASGI. I'm
using dictionaries to keep it simple and to make adding additional
options in the future easy.

Fixes #440
2019-05-01 16:01:56 -07:00
Simon Willison bac4e01f40 Ensure sqlite_timelimit correctly clears handler
If an error occurred inside the block the progress handler (used to
enforce a time limit) was not being correctly cleared, resulting in
timeout errors potentially occurring during subsequent SQL queries.

The fix is described here: https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager
2019-04-21 12:02:24 -07:00
Simon Willison 11b352b4d5 Fix for Python 3.5, refs #435 2019-04-21 11:20:20 -07:00
Simon Willison 9d73e3c8bd Note that trace data format is very likely to change, refs #435 2019-04-21 10:53:28 -07:00
Simon Willison e4e73a537a Test for ?_trace=1, refs #435 2019-04-21 10:46:56 -07:00
Simon Willison 58a862cee4 ?_trace=1 now adds SQL trace info to JSON/HTML response
Also added documentation for it. Refs #435
2019-04-21 10:41:16 -07:00
Simon Willison 7d01ca34a1 Added ?_trace=1 option to trace SQL
Currently just dumps all SQL statements out on the console.
2019-04-20 22:34:34 -07:00