simonw / datasette

An open source multi-tool for exploring and publishing data
https://datasette.io
Apache License 2.0
9.6k stars 690 forks source link

Consider releasing a 0.65 with some forwards compatibility for 1.0 #2335

Open simonw opened 7 months ago

simonw commented 7 months ago

With 1.0 growing ever closer, I'm running into some problems with plugins. datasette-secrets is currently only compatible with 1.0a+ because of the way it uses the new permissions infrastructure from 1.0. But I want a bunch of other plugins to make use of datasette-secrets:

And this means that those plugins will stop working with Datasette <1.0 due to that dependency.

I looked into changing datasette-secrets to be compatible with both versions and it's a tiny bit inconvenient mainly because the test suite uses some conveniences in 1.0 - this for example:

@pytest.fixture
def ds():
    return Datasette(
        config={
            "plugins": {
                "datasette-secrets": {
                    "database": "_internal",
                    "encryption-key": TEST_ENCRYPTION_KEY,
                }
            },
            "permissions": {"manage-secrets": {"id": "admin"}},
        }
    )

That permissions piece of configuration is a much more convenient way of testing permissions.

Some options:

  1. Ignore this. Have more plugins that require 1.0a+ and hurry towards a 1.0 proper release
  2. Expand the https://github.com/datasette/datasette-test tool which is already intended to help paper over gaps between the two versions
  3. Release a 0.65 which backports some of these conveniences from 1.0, such that it's pleasant and easy to write tests that work in both

I already have a good pattern for running CI against both versions, as seen here: https://github.com/simonw/datasette-configure-fts/blob/1.1.3/.github/workflows/test.yml

simonw commented 7 months ago

Option 1. is where we are now, and it's beginning to suck.

Option 2 is plausible? My datasette-secrets plugin failed on from datasette import Permission - but maybe I could have that class in <1.0 without it doing anything useful, just so plugins can start using register_permissions()? Bit messy though.

What's the minimal work I could do for option 3 to be worthwhile I wonder?

simonw commented 7 months ago

After browsing through https://github.com/simonw/datasette/compare/0.64.6...1.0a13 a bit I think a full forward-porting of the permissions work would be too hard. But having a Permission class that can be imported and does nothing except for allow register_permissions() to be called for 1.0a+ might be worthwhile.

The rest of the problem could then be solved in datasette-test. Maybe something like this:

from datasette_test import Datasette

ds = Datasette(
    plugin_config={"datasette-extract": "..."},
    permissions={"manage-secrets": {"id": "admin"}}
)

Where that permissions= thing uses config={"permissions": ...} for Datasette 1.0a+ and some more complex plugin-based mechanism for <1.0.