swindl 3.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. swindl-3.2.0/.flake8 +18 -0
  2. swindl-3.2.0/.githooks/pre-push +35 -0
  3. swindl-3.2.0/.github/dependabot.yml +10 -0
  4. swindl-3.2.0/.github/workflows/pages.yml +78 -0
  5. swindl-3.2.0/.github/workflows/publish.yml +64 -0
  6. swindl-3.2.0/.github/workflows/test.yml +55 -0
  7. swindl-3.2.0/.gitignore +8 -0
  8. swindl-3.2.0/CHANGELOG.md +186 -0
  9. swindl-3.2.0/CLAUDE.md +132 -0
  10. swindl-3.2.0/LICENSE +21 -0
  11. swindl-3.2.0/PKG-INFO +86 -0
  12. swindl-3.2.0/PLAN.md +199 -0
  13. swindl-3.2.0/README.md +49 -0
  14. swindl-3.2.0/SECURITY.md +19 -0
  15. swindl-3.2.0/benchmarks/RESULTS.md +52 -0
  16. swindl-3.2.0/benchmarks/bench.py +973 -0
  17. swindl-3.2.0/benchmarks/results.json +527 -0
  18. swindl-3.2.0/doc/guarantees.md +131 -0
  19. swindl-3.2.0/doc/license.conf +8 -0
  20. swindl-3.2.0/doc/reference.md +488 -0
  21. swindl-3.2.0/doc/webadapter.md +208 -0
  22. swindl-3.2.0/examples/collection/README.md +145 -0
  23. swindl-3.2.0/examples/collection/pyproject.toml +29 -0
  24. swindl-3.2.0/examples/collection/swindl_collection/__init__.py +14 -0
  25. swindl-3.2.0/examples/collection/swindl_collection/__main__.py +42 -0
  26. swindl-3.2.0/examples/collection/swindl_collection/app.py +191 -0
  27. swindl-3.2.0/examples/collection/swindl_collection/app_test.py +224 -0
  28. swindl-3.2.0/examples/collection/swindl_collection/catalog.py +211 -0
  29. swindl-3.2.0/examples/collection/swindl_collection/demo.py +97 -0
  30. swindl-3.2.0/examples/collection/swindl_collection/model.py +189 -0
  31. swindl-3.2.0/examples/collection/swindl_collection/static/collection.css +47 -0
  32. swindl-3.2.0/examples/collection/swindl_collection/static/collection.js +5 -0
  33. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/_field.j2 +9 -0
  34. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/collection_form.j2 +36 -0
  35. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/collections.j2 +23 -0
  36. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/facets.j2 +28 -0
  37. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/import_form.j2 +29 -0
  38. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/item_form.j2 +53 -0
  39. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/login.j2 +24 -0
  40. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/page.j2 +79 -0
  41. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/public.j2 +39 -0
  42. swindl-3.2.0/examples/collection/swindl_collection/templates/collection/results.j2 +61 -0
  43. swindl-3.2.0/examples/collection/swindl_collection/views.py +434 -0
  44. swindl-3.2.0/examples/store.py +134 -0
  45. swindl-3.2.0/examples/webadapter.py +154 -0
  46. swindl-3.2.0/pyproject.toml +80 -0
  47. swindl-3.2.0/setup.cfg +4 -0
  48. swindl-3.2.0/site/.gitignore +13 -0
  49. swindl-3.2.0/site/Makefile +90 -0
  50. swindl-3.2.0/site/README.md +45 -0
  51. swindl-3.2.0/site/benchmarks.md +72 -0
  52. swindl-3.2.0/site/content/_index.md +126 -0
  53. swindl-3.2.0/site/hugo.toml +56 -0
  54. swindl-3.2.0/site/layouts/_default/baseof.html +19 -0
  55. swindl-3.2.0/site/layouts/_default/single.html +10 -0
  56. swindl-3.2.0/site/layouts/index.html +5 -0
  57. swindl-3.2.0/site/layouts/partials/footer.html +12 -0
  58. swindl-3.2.0/site/layouts/partials/header.html +9 -0
  59. swindl-3.2.0/site/page.sh +8 -0
  60. swindl-3.2.0/site/pdf/reference.lua +44 -0
  61. swindl-3.2.0/site/pdf/reference.typ +92 -0
  62. swindl-3.2.0/site/pdf/seecr-logo.png +0 -0
  63. swindl-3.2.0/site/static/css/site.css +249 -0
  64. swindl-3.2.0/site/static/css/syntax.css +155 -0
  65. swindl-3.2.0/site/static/img/seecr-logo.png +0 -0
  66. swindl-3.2.0/swindl/__init__.py +16 -0
  67. swindl-3.2.0/swindl/_version.py +24 -0
  68. swindl-3.2.0/swindl/check.py +207 -0
  69. swindl-3.2.0/swindl/check_test.py +111 -0
  70. swindl-3.2.0/swindl/oai/__init__.py +34 -0
  71. swindl-3.2.0/swindl/oai/downloader.py +316 -0
  72. swindl-3.2.0/swindl/oai/downloader_test.py +393 -0
  73. swindl-3.2.0/swindl/oai/provider.py +615 -0
  74. swindl-3.2.0/swindl/oai/provider_test.py +388 -0
  75. swindl-3.2.0/swindl/oai/repository.py +356 -0
  76. swindl-3.2.0/swindl/oai/repository_test.py +210 -0
  77. swindl-3.2.0/swindl/store/__init__.py +20 -0
  78. swindl-3.2.0/swindl/store/base.py +39 -0
  79. swindl-3.2.0/swindl/store/base_test.py +49 -0
  80. swindl-3.2.0/swindl/store/crash_test.py +131 -0
  81. swindl-3.2.0/swindl/store/dump.py +75 -0
  82. swindl-3.2.0/swindl/store/indexes.py +307 -0
  83. swindl-3.2.0/swindl/store/indexes_test.py +119 -0
  84. swindl-3.2.0/swindl/store/store.py +350 -0
  85. swindl-3.2.0/swindl/store/store_test.py +358 -0
  86. swindl-3.2.0/swindl/store/utils.py +17 -0
  87. swindl-3.2.0/swindl/webadapter.py +262 -0
  88. swindl-3.2.0/swindl/webadapter_test.py +284 -0
  89. swindl-3.2.0/swindl.egg-info/PKG-INFO +86 -0
  90. swindl-3.2.0/swindl.egg-info/SOURCES.txt +95 -0
  91. swindl-3.2.0/swindl.egg-info/dependency_links.txt +1 -0
  92. swindl-3.2.0/swindl.egg-info/entry_points.txt +3 -0
  93. swindl-3.2.0/swindl.egg-info/requires.txt +8 -0
  94. swindl-3.2.0/swindl.egg-info/scm_file_list.json +90 -0
  95. swindl-3.2.0/swindl.egg-info/scm_version.json +8 -0
  96. swindl-3.2.0/swindl.egg-info/top_level.txt +1 -0
  97. swindl-3.2.0/tools/crashtest.py +229 -0
swindl-3.2.0/.flake8 ADDED
@@ -0,0 +1,18 @@
1
+ [flake8]
2
+ exclude =
3
+ .git,
4
+ __pycache__,
5
+ build,
6
+ dist,
7
+ # the virtual environment
8
+ env,
9
+ extend-ignore =
10
+ # E266 too many leading '#' for block comment (the license header)
11
+ E266,
12
+ # E203 whitespace before ':' (black puts it in slices)
13
+ E203,
14
+ per-file-ignores =
15
+ # unused imports in __init__
16
+ swindl/__init__.py:F401
17
+ swindl/*/__init__.py:F401,F403
18
+ max-line-length = 88
@@ -0,0 +1,35 @@
1
+ #!/bin/sh
2
+ # Before `git push`: flake8, isort and the tests, so a push does not bring broken or
3
+ # unformatted code to others. Turn it on once per clone:
4
+ #
5
+ # git config core.hooksPath .githooks
6
+ #
7
+ # flake8 and isort come from the dev dependency group in pyproject.toml
8
+ # (pip install -e . --group dev). Push anyway (e.g. work in progress on a branch): git push --no-verify
9
+
10
+ cd "$(git rev-parse --show-toplevel)" || exit 1
11
+
12
+ # the project's virtualenv if there is one, else whatever python is active
13
+ PYTHON=python3
14
+ [ -x env/bin/python ] && PYTHON=env/bin/python
15
+
16
+ fail() {
17
+ echo
18
+ echo "pre-push: $1; not pushed (git push --no-verify to push anyway)"
19
+ exit 1
20
+ }
21
+
22
+ for tool in flake8 isort; do
23
+ "$PYTHON" -m $tool --version > /dev/null 2>&1 ||
24
+ fail "$tool is missing: $PYTHON -m pip install -e . --group dev"
25
+ done
26
+
27
+ echo "pre-push: flake8"
28
+ "$PYTHON" -m flake8 swindl examples tools benchmarks || fail "flake8 found problems"
29
+
30
+ echo "pre-push: isort"
31
+ "$PYTHON" -m isort --check-only --diff swindl examples tools benchmarks ||
32
+ fail "imports not sorted (isort swindl examples tools)"
33
+
34
+ echo "pre-push: tests"
35
+ "$PYTHON" -m pytest -q swindl || fail "tests failed"
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ # Keeps the action versions in .github/workflows up to date.
4
+ - package-ecosystem: github-actions
5
+ directory: /
6
+ schedule:
7
+ interval: monthly
8
+ groups:
9
+ actions:
10
+ patterns: ["*"]
@@ -0,0 +1,78 @@
1
+ name: Publish website
2
+
3
+ # Builds site/ (Hugo, with the references of swindl, sjdbl and sil as pages and PDFs) and
4
+ # publishes it to GitHub Pages at https://swindl.seecr.nl/. Runs after "Publish to PyPI"
5
+ # has succeeded for a version tag, building from that tag, so the site shows the released
6
+ # reference. It can also be run by hand (Actions > Publish website > Run workflow) from any
7
+ # branch. sjdbl and sil are checked out next to swindl (as the Makefile expects), at their
8
+ # default branch; the versions on their pages are their latest tags.
9
+ on:
10
+ workflow_run:
11
+ workflows: ["Publish to PyPI"]
12
+ types: [completed]
13
+ workflow_dispatch:
14
+
15
+ permissions:
16
+ contents: read
17
+ pages: write
18
+ id-token: write
19
+
20
+ concurrency:
21
+ group: pages
22
+ cancel-in-progress: false
23
+
24
+ jobs:
25
+ build:
26
+ if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
27
+ runs-on: ubuntu-latest
28
+ defaults:
29
+ run:
30
+ working-directory: swindl/site
31
+ steps:
32
+ - uses: actions/checkout@v7
33
+ with:
34
+ ref: ${{ github.event.workflow_run.head_sha || github.ref }}
35
+ path: swindl
36
+ fetch-depth: 0 # the version on the site comes from the tags
37
+ - uses: actions/checkout@v7
38
+ with:
39
+ repository: seecr/sjdbl
40
+ path: sjdbl
41
+ fetch-depth: 0
42
+ - uses: actions/checkout@v7
43
+ with:
44
+ repository: seecr/sil
45
+ path: sil
46
+ fetch-depth: 0
47
+ - name: Install pandoc and Typst
48
+ working-directory: ${{ runner.temp }}
49
+ run: |
50
+ curl -sSfLo pandoc.deb \
51
+ https://github.com/jgm/pandoc/releases/download/3.9.0.2/pandoc-3.9.0.2-1-amd64.deb
52
+ sudo dpkg -i pandoc.deb
53
+ curl -sSfL https://github.com/typst/typst/releases/download/v0.15.1/typst-x86_64-unknown-linux-musl.tar.xz \
54
+ | tar xJ
55
+ sudo mv typst-x86_64-unknown-linux-musl/typst /usr/local/bin/
56
+ pandoc --version | head -1
57
+ typst --version
58
+ - uses: peaceiris/actions-hugo@v3
59
+ with:
60
+ hugo-version: "0.152.2"
61
+ extended: true
62
+ - id: pages
63
+ uses: actions/configure-pages@v6
64
+ - name: Build
65
+ run: make build HUGO_FLAGS="--baseURL ${{ steps.pages.outputs.base_url }}/"
66
+ - uses: actions/upload-pages-artifact@v5
67
+ with:
68
+ path: swindl/site/public
69
+
70
+ deploy:
71
+ needs: build
72
+ runs-on: ubuntu-latest
73
+ environment:
74
+ name: github-pages
75
+ url: ${{ steps.deployment.outputs.page_url }}
76
+ steps:
77
+ - id: deployment
78
+ uses: actions/deploy-pages@v5
@@ -0,0 +1,64 @@
1
+ name: Publish to PyPI
2
+
3
+ # Publishes when a MAJOR.MINOR.PATCH tag (e.g. 0.6.0) is pushed. The tag
4
+ # becomes the package version via setuptools_scm. After the upload, a GitHub
5
+ # release is made with that version's section of CHANGELOG.md.
6
+ on:
7
+ push:
8
+ tags: ["[0-9]+.[0-9]+.[0-9]+"]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v7
15
+ with:
16
+ fetch-depth: 0
17
+ - uses: actions/setup-python@v7
18
+ with:
19
+ python-version: "3.13"
20
+ - name: CHANGELOG.md has a section for this version
21
+ run: grep -q "^## $GITHUB_REF_NAME " CHANGELOG.md
22
+ - run: pip install build twine
23
+ - run: python -m build
24
+ - run: twine check --strict dist/*
25
+ - uses: actions/upload-artifact@v7
26
+ with:
27
+ name: dist
28
+ path: dist/
29
+
30
+ publish:
31
+ needs: build
32
+ runs-on: ubuntu-latest
33
+ environment:
34
+ name: pypi
35
+ url: https://pypi.org/project/swindl/
36
+ permissions:
37
+ id-token: write # PyPI trusted publishing, no API token needed
38
+ steps:
39
+ - uses: actions/download-artifact@v8
40
+ with:
41
+ name: dist
42
+ path: dist/
43
+ - uses: pypa/gh-action-pypi-publish@release/v1
44
+
45
+ release:
46
+ needs: publish
47
+ runs-on: ubuntu-latest
48
+ permissions:
49
+ contents: write # to create the release
50
+ steps:
51
+ - uses: actions/checkout@v7
52
+ - uses: actions/download-artifact@v8
53
+ with:
54
+ name: dist
55
+ path: dist/
56
+ - name: Release notes from CHANGELOG.md
57
+ run: |
58
+ awk -v v="$GITHUB_REF_NAME" '/^## /{p = ($2 == v)} p && !/^## /' CHANGELOG.md > notes.md
59
+ if ! grep -q . notes.md; then
60
+ echo "See [CHANGELOG.md](https://github.com/seecr/swindl/blob/master/CHANGELOG.md)." > notes.md
61
+ fi
62
+ - run: gh release create "$GITHUB_REF_NAME" dist/* --title "$GITHUB_REF_NAME" --notes-file notes.md
63
+ env:
64
+ GH_TOKEN: ${{ github.token }}
@@ -0,0 +1,55 @@
1
+ name: Tests
2
+
3
+ # Version tags are tested by the push of the commit itself; publish.yml handles the tag.
4
+ on:
5
+ push:
6
+ branches: ["**"]
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
16
+ steps:
17
+ - uses: actions/checkout@v7
18
+ with:
19
+ fetch-depth: 0 # setuptools_scm needs the tags
20
+ - uses: actions/setup-python@v7
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+ - run: python -m pip install --upgrade pip # --group needs pip 25.1
24
+ - run: pip install -e . --group dev
25
+ - run: python -m pytest swindl
26
+ - name: The examples run
27
+ run: for f in examples/*.py; do PYTHONPATH=. python "$f" > /dev/null || exit 1; done
28
+
29
+ collection:
30
+ # The example application (SWL + swindl), against this checkout.
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@v7
34
+ with:
35
+ fetch-depth: 0 # setuptools_scm needs the tags
36
+ - uses: actions/setup-python@v7
37
+ with:
38
+ python-version: "3.13"
39
+ - run: python -m pip install --upgrade pip # --group needs pip 25.1
40
+ - run: pip install -e . --group dev
41
+ - run: pip install -e examples/collection
42
+ - run: python -m pytest swindl_collection
43
+ working-directory: examples/collection
44
+
45
+ flake8:
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - uses: actions/checkout@v7
49
+ - uses: actions/setup-python@v7
50
+ with:
51
+ python-version: "3.13"
52
+ - run: python -m pip install --upgrade pip # --group needs pip 25.1
53
+ - run: pip install --group dev
54
+ - run: flake8 swindl examples tools benchmarks
55
+ - run: isort --check-only --diff swindl examples tools benchmarks
@@ -0,0 +1,8 @@
1
+ env/
2
+ swindl/_version.py
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ __pycache__/
7
+ .pytest_cache/
8
+ collection-data/
@@ -0,0 +1,186 @@
1
+ # Changelog
2
+
3
+ ## 3.2.0 (2026-11-24)
4
+
5
+ ### Changed
6
+
7
+ - Needs sil as `seecr-sil >= 3.4.0` (sil is on PyPI under that name; the import stays
8
+ `sil`). In an existing virtualenv, `pip uninstall sil` first: both install the `sil`
9
+ package.
10
+ - Needs sjdbl >= 0.6.0 and seecr-stdlib >= 0.7.0 (both on PyPI). lxml and tantivy,
11
+ which swindl imports itself, are named as dependencies (they came with sjdbl and sil).
12
+ - setuptools-scm is no longer installed with swindl (it is only needed to build it);
13
+ pytest, pytest-asyncio and pytest-xdist stay (the tests are part of the package). The
14
+ dev tools (flake8, isort) are the `dev` dependency group in `pyproject.toml` (`pip install -e . --group dev`);
15
+ `requirements-dev.txt` is gone.
16
+ - The package metadata names the license as an SPDX expression (`MIT`).
17
+
18
+ ### Added
19
+
20
+ - Published on GitHub (https://github.com/seecr/swindl) and PyPI (`pip install
21
+ swindl`): project URLs and classifiers in the metadata, tests in GitHub Actions, and a
22
+ release to PyPI for every version tag.
23
+ - The website, https://swindl.seecr.nl/, with the references of swindl, sjdbl and sil,
24
+ published after every release.
25
+
26
+ ## 3.1.0 (2026-11-20)
27
+
28
+ ### Added
29
+
30
+ - `swindl.oai`: OAI-PMH administration in the store (`Oai`, `OaiRecord`), as
31
+ meresco-oai's OaiJazz: prefixes, hierarchical sets, deletes (in prefixes, in sets,
32
+ `always_delete_in_prefixes`), unique increasing stamps, `select` for lists. See
33
+ "OAI-PMH" in `doc/reference.md`.
34
+ - `swindl.oai.provider.OaiProvider`: OAI-PMH 2.0 provider for an `Oai`, as
35
+ meresco-oai answered (XML, errors, resumption tokens), with x-wait; independent of a
36
+ web framework. `delete_in_sets=False` leaves the setSpecs unmarked (as meresco's
37
+ OaiPmh could); `about` may give `""` for an empty `<about>`.
38
+ - `swindl.oai.OaiDownloader`: harvests an OAI-PMH repository into the store, each part
39
+ with its position in one transaction; x-wait or an interval; a parser of its own
40
+ (`parser=`, e.g. `huge_tree`).
41
+ - `Store.on_transaction(listener)`: called with the changes after every transaction.
42
+ - `Store.sees_changes_at_once`: whether a search finds a change as soon as its
43
+ transaction is done (`Commit(immediate=True)` or `Commit(on_search=True)`).
44
+
45
+ ## 3.0.0 (2026-11-16)
46
+
47
+ Crash-safe transactions over files and index. Needs sjdbl 0.4.0 and sil 3.2.0.
48
+
49
+ **Reindex after upgrading** (`store.reindex(models)`, e.g. the `actions/reindex` file at
50
+ startup). sil 3.2.0 fixes a bug that could leave an old version of an updated object in
51
+ the index next to the new one (it then shows twice in a list); the reindex removes those.
52
+ And an index with a `sortable=True` text or untokenized field changes schema (faster
53
+ sorting) and starts empty until it is reindexed.
54
+
55
+ ### License
56
+
57
+ - swindl is now MIT licensed (was GPLv2), like SWL. So are sjdbl (0.4.0) and sil
58
+ (3.2.0).
59
+
60
+ ### Breaking changes
61
+
62
+ - `Store.batch()` is replaced by `Store.transaction()`: all puts and deletes of the block
63
+ are stored together at its end, or none of them. A failing block now stores nothing
64
+ (with `batch()` its puts stayed in the files and the index).
65
+ - swindl commits the indexes itself; sil's own commit task is not used any more.
66
+ `Indexes.deferred_commit()` is gone (`Indexes.deferred()` is its replacement inside
67
+ swindl).
68
+
69
+ ### Added
70
+
71
+ - `Store.transaction()`. See "Transactions" in `doc/reference.md`.
72
+ - `Store.commit()`: commit the indexes now (for `Commit(timeout=0)`).
73
+ - `Commit(on_search=True)`: a save commits nothing; the next search commits first, so
74
+ it finds everything saved before it. Many saves without a search in between share one
75
+ commit: for harvesting, or many updates at once. A change then costs about a
76
+ millisecond instead of a commit.
77
+ - Crash safety. The files have a transaction completely or not at all (sjdbl 0.4.0), and
78
+ the index catches up: the qids of a transaction go to `index/pending.log` before the
79
+ files are committed and leave it after the index has committed them; when the store is
80
+ opened, what is still in it is indexed again from the files. See "After a crash".
81
+ - `swindl-check <data dir> <models>`: reports whether the index matches the files
82
+ (and leftovers of a crash, unreadable files, dangling references). Changes nothing.
83
+ - `doc/guarantees.md`: what swindl promises, what not, the limits, backups.
84
+ - `tools/crashtest.py`: kills a process running transactions at random moments, many
85
+ times, and checks after each kill.
86
+ - `Store.reindex()` commits once at the end (it used to commit after every object with
87
+ `Commit(immediate=True)`).
88
+
89
+ ### Upgrading from 2.x
90
+
91
+ - `with store.batch():` becomes `with store.transaction():`. Code that relied on the puts
92
+ of a failing block being kept should catch the exception inside the block.
93
+ - A subclass of `Store` that overrides `batch()` overrides `transaction()` instead.
94
+ - Within a transaction other threads no longer see its changes through `get()` before
95
+ the block ends.
96
+
97
+ ### Changed
98
+
99
+ - The wheel only has the package itself (`swindl/`); it used to install `doc/`, `examples/` and
100
+ other directories of the repository into site-packages too.
101
+
102
+ ## 2.2.1 (2026-11-16)
103
+
104
+ ### Fixed
105
+
106
+ - Changes from several threads (plain `def` endpoints run in Starlette's thread pool) are
107
+ safe: `put()`, `delete()` and `reindex()` hold one lock around the files and the index.
108
+ Before, a slow thread could give the index older values than the files had, and the
109
+ cache of indexed values could raise a `KeyError`.
110
+ - `query()`, `list()` and `find_by_field()` skip a hit whose file is gone (deleted
111
+ between the search and the read, or left in the index by a crash between the file
112
+ delete and the index delete). They used to return `None` among the objects.
113
+
114
+ ## 2.2.0 (2026-11-10)
115
+
116
+ ### Added
117
+
118
+ - `Store.delete()` also takes a reference to an object (sjdbl's `Proxy`, as references and
119
+ collections give) or its qid, and deletes it from the files and the index without
120
+ loading it. A reference used to fail ("No qid found"), and a qid deleted the file but
121
+ then failed before the index. For an object nothing changes.
122
+
123
+ ## 2.1.0 (2026-11-10)
124
+
125
+ Needs sil 3.1.0 (for `Index.deferred_commit`) and sjdbl 0.3.1.
126
+
127
+ **Reindex after upgrading** when a model has an `IndexField.int`: sil 3.1.0 makes int fields
128
+ fast fields (a range query reads the column), which changes the index schema. An existing
129
+ index with int fields is recreated empty; rebuild it with `store.reindex(models)` (e.g. the
130
+ `actions/reindex` file at startup, see "Reindexing" in `doc/reference.md`).
131
+
132
+ ### Added
133
+
134
+ - `Store.batch()`: a block of puts with one commit of the index at its end, instead of one
135
+ per put (`Commit(immediate=True)`). Hundreds of puts go from seconds to under one. Within
136
+ the block queries don't see its puts yet; a delete is still committed at once. See
137
+ "Storing" in `doc/reference.md`.
138
+
139
+ ## 2.0.0 (2026-11-06)
140
+
141
+ A new WebAdapter: a form saves only what it sends, empty dates and numbers can be
142
+ cleared, and wrong values give an error per field instead of a crash. See
143
+ `doc/webadapter.md`. Needs sjdbl 0.3.0.
144
+
145
+ ### Breaking changes
146
+
147
+ - `swindl.webadapter` is rewritten; its API is new (see "Upgrading from 1.x").
148
+ - `swindl.store.Base` is swindl's own subclass of sjdbl's `Base`, with `INDEX = []` and
149
+ `ADAPTATIONS = []`. sjdbl 0.3.0 no longer has `INDEX`: a model built on sjdbl's `Base`
150
+ directly gets no index any more.
151
+ - Raised at import, when the model class is defined: an `Adapt` for a name that is not a
152
+ field, a field adapted twice (swindl), and a field name used twice or clashing with an
153
+ attribute of `Base` such as `id`, `qid` or `update` (sjdbl 0.3.0).
154
+
155
+ ### Added
156
+
157
+ - `from_form(model, form, fields, obj=None, adaptations=None)`: the converted and checked
158
+ values of a form, for `update` or `create`. Not sent is left alone (a checkbox is
159
+ `False`), empty is `None` (text: `""`), all errors in one `FormErrors`.
160
+ - `to_form(obj, fields, form=None, adaptations=None)`: the values for the inputs of a
161
+ form, or with `form=` what was typed, to show a form again after errors.
162
+ - Checks `at_least`, `at_most`, `max_length` and `one_of`; `FieldError(code, **params)`
163
+ for checks of your own.
164
+ - `Adapt.custom(name, from_web(obj, form), to_web(obj, value))`.
165
+ - `doc/reference.md`, `examples/` and this changelog.
166
+
167
+ ### Upgrading from 1.x
168
+
169
+ Pin `swindl >= 1.2, < 2` until an application is converted; an application that pins swindl
170
+ without an upper bound should get `< 2` first.
171
+
172
+ - Import `Base` from `swindl.store`, not from `sjdbl.base`, for every model that is indexed
173
+ or has `ADAPTATIONS`.
174
+ - `WebAdapter.adapt(obj, form, fields)` becomes `from_form(type(obj), form, fields,
175
+ obj=obj)`.
176
+ - The wrapper `WebAdapter(obj)` is gone: use `to_form(obj, fields)` for form inputs, and
177
+ template filters (`format_date`, `format_number`) on the object to show values.
178
+ - `Adapt.method(name, from_web, to_web)` becomes `Adapt.custom(name, from_web, to_web)`;
179
+ `from_web` now gets `(obj, form)` and `to_web` `(obj, value)`.
180
+ - Not sent is left alone, empty is `None`, and wrong values raise `FormErrors`: a view that
181
+ saves a form catches `FormErrors` and shows the form again with
182
+ `to_form(obj, fields, form=form)` and the errors. A workaround that only passes the
183
+ fields that were sent is no longer needed.
184
+ - Error messages are the application's: translate `error.code` with `error.params`.
185
+ - An `Adapt` that names no field, and a field name that clashes with `Base`, now raise at
186
+ import: fix the name.
swindl-3.2.0/CLAUDE.md ADDED
@@ -0,0 +1,132 @@
1
+ # swindl – Seecr Web Index and Database Lib
2
+
3
+ The storage side of an SWL application: sjdbl's JSON files (objects) and sil's index
4
+ (searching) behind one `Store`, plus the WebAdapter that converts and checks what comes
5
+ in from a web form. MIT licensed. Maintained by Seecr (Johan Jonkers, Thijs Janssen).
6
+ `doc/reference.md` is the user-facing reference; keep it in step with the code.
7
+
8
+ ## Layout
9
+
10
+ - `swindl/store/base.py` – `Base`: sjdbl's `Base` with `INDEX` and `ADAPTATIONS`; checks
11
+ at class definition that every `Adapt` names a field. Models import it from
12
+ `swindl.store`.
13
+ - `swindl/store/store.py` – `Store` (create/put/get/list/query/find_one/find_by_field/
14
+ archive/delete/transaction/reindex, recovery at open), `QueryParams`, `QueryResult`,
15
+ `Pages`, `HasChangedException`
16
+ - `swindl/store/indexes.py` – `Indexes` (one sil `Index` per model with an `INDEX`; does
17
+ the commits itself), `Commit` (when changes become searchable), `PendingLog`, `Query`
18
+ (query text plus exact terms)
19
+ - `swindl/oai/` – OAI-PMH: `repository.py` (`Oai`, `OaiRecord`, `OaiRepository`:
20
+ OaiJazz's administration in the store; keep its semantics, they are what meresco
21
+ clients got), `provider.py` (`OaiProvider`: meresco-oai's XML, errors and tokens; x-wait
22
+ wakes requests from `Store.on_transaction` via `loop.call_soon_threadsafe`, with a
23
+ change counter so a change between select and wait is not missed), `downloader.py`
24
+ (`OaiDownloader`: a part and its position in one transaction; the in-memory state is
25
+ reloaded when that transaction fails)
26
+ - `swindl/check.py` – `swindl-check`: index vs files, crash leftovers, dangling
27
+ references. Only reads (no Store, no recovery); keep it that way.
28
+ - `site/` – the website of swindl, sjdbl and sil (Hugo; pages and PDFs made from the
29
+ docs of the three repositories, see `site/README.md`)
30
+ - `benchmarks/bench.py` – swindl against SQLite + FTS5 on the same data; results in
31
+ `benchmarks/RESULTS.md` (not in the package)
32
+ - `tools/crashtest.py` – SIGKILLs a process running transactions, hundreds of times;
33
+ run before a release that touches the commit path (not in the package)
34
+ - `doc/guarantees.md` – what is promised and what not; keep it in step with the code
35
+ - `swindl/store/crash_test.py` – real crashes (a child process that `os._exit`s) at each
36
+ step of a transaction
37
+ - `swindl/webadapter.py` – `from_form`, `to_form`, `Adapt`, the checks (`at_least`,
38
+ `at_most`, `max_length`, `one_of`), `FieldError`, `FormErrors`
39
+ - `swindl/store/dump.py` – `swindl-load-sdbl-dump`: converts an old sdbl dump. Transient,
40
+ for migrations only; keep it out of the reference.
41
+ - `doc/reference.md` – the reference; `doc/webadapter.md` – the WebAdapter in full
42
+ (principles, rules, a complete view, why no library); `CHANGELOG.md` – keep it updated,
43
+ with "Upgrading" notes for breaking changes
44
+ - `examples/` – runnable scripts, explained step by step (`store.py`, `webadapter.py`)
45
+ - `examples/collection/` – an example application (SWL + swindl): collections of records,
46
+ LEGO sets; its own pyproject and README. Generic names only, no customer projects.
47
+
48
+ ## Commands
49
+
50
+ ```sh
51
+ pytest swindl # the tests (-n5: pytest-xdist)
52
+ flake8 swindl examples tools && isort --check-only swindl examples tools
53
+ PYTHONPATH=. python examples/store.py # an example against this checkout
54
+ PYTHONPATH=. python examples/webadapter.py
55
+ pytest examples/collection/swindl_collection # needs swl: pip install -e examples/collection
56
+ PYTHONPATH=. python tools/crashtest.py --rounds 500 # before a release of the commit path
57
+ ```
58
+
59
+ `env/` is the virtualenv (see the seecr-python rebuild-venv skill); the dev tools
60
+ (flake8, isort) are the `dev` dependency group in `pyproject.toml`:
61
+ `env/bin/pip install -e . --group dev`. All dependencies are on PyPI (sil as
62
+ `seecr-sil`; the import stays `sil`), reached through Seecr's devpi. To work against a
63
+ local sjdbl checkout: `pip install -e ../sjdbl`.
64
+
65
+ Releasing: give the version a `## X.Y.Z (date)` section in `CHANGELOG.md`, then push
66
+ the tag `X.Y.Z` to GitHub; `.github/workflows/publish.yml` builds it, uploads it to
67
+ PyPI (trusted publishing) and makes the GitHub release. The tag is the version
68
+ (setuptools-scm). After that, `.github/workflows/pages.yml` publishes `site/` to
69
+ https://swindl.seecr.nl/ (GitHub Pages).
70
+
71
+ ## Design decisions (deliberate, don't re-propose)
72
+
73
+ - Explicit over implicit, KISS. No reindex in application code because a model changed:
74
+ a reindex is an explicit step (announced in the CHANGELOG, done via `actions/reindex`,
75
+ i.e. `store.reindex(models)`), and swindl only reports that one is needed
76
+ (`needs_reindex`). Finishing an interrupted commit from the commit log at startup is
77
+ part of a transaction, not a reindex. No adaptations derived from `FIELDS`.
78
+ - Fields define the model; the WebAdapter guards the boundary. No web or check knowledge
79
+ in sjdbl's `Field`, no conversions derived from `Field`s. `update`/`create` trust their
80
+ input; checking is the WebAdapter's.
81
+ - The WebAdapter (design in `doc/webadapter.md`, agreed November 2026) stays our own;
82
+ WTForms, Pydantic and marshmallow were considered and don't fit. Its rules, per field:
83
+ not in `fields`, never touched; not sent, left alone, except a checkbox (`False`); sent,
84
+ stripped, empty is `None` (text `""`); then converted (`invalid_<type>`) and checked.
85
+ `Adapt.custom` gets `(obj, form)` and decides. All errors in one `FormErrors`.
86
+ - Forms only: `to_form` gives values for inputs; showing values is template filters. No
87
+ wrapper object around models.
88
+ - Simple data: results and errors are plain dicts; errors are a code and params, without
89
+ messages. swindl does not translate and does not depend on SWL.
90
+ - Choices are the check `one_of(values)`, built where the values are known (the model for
91
+ a fixed list, the view for a list from the store). No `choices=` argument.
92
+
93
+ ## Invariants to keep
94
+
95
+ - Every change is a transaction (`put`/`delete` alone are one each), with `Store._lock`
96
+ held: qids to `index/pending.log` (synced) → sjdbl commits the files → the index
97
+ changes → commit (immediate, or the timer) → `pending.log` emptied. The pending log is
98
+ only emptied by `Indexes.commit()`, which holds the same lock, so never in the middle of
99
+ a transaction. At open, `Store._recover` indexes the pending qids again from the files.
100
+ - sil's own commit task is off (`commit_timeout=0`); swindl's `Indexes` runs the timer
101
+ (`asyncio.to_thread(self.commit)`) and commits only indexes with changes.
102
+ - A delete is committed at the end of its transaction, except with `on_search`.
103
+ - `Commit(on_search=True)`: no commit after a change; every search method of `Indexes`
104
+ calls `_commit_before_search()` first (commits all changed indexes and empties the
105
+ pending log, under the lock). A new search method must call it too.
106
+ - `put()` stores in sjdbl and then indexes. `Indexes.add_record` skips the index when the
107
+ indexed values of that object did not change since the last put (bounded cache,
108
+ `INDEXED_CACHE_SIZE`; forgetting only means indexing again).
109
+ - Every index has `__id__` and `__archived__` (`"True"`/`"False"`) besides the model's
110
+ `INDEX`; `list()` filters on `__archived__`, `query()` does not.
111
+ - `get()` reads the files, never the index; `query()` gets ids from the index and reads the
112
+ objects from the files.
113
+ - `get(qrid)` raises `HasChangedException` when the revision on disk differs.
114
+
115
+ ## Conventions
116
+
117
+ - Every source file starts with the Swindl license header (copy it from
118
+ `swindl/webadapter.py`); `doc/license.conf` describes it.
119
+ - Code style: black, isort with the black profile (`pyproject.toml`), flake8 (`.flake8`);
120
+ lines up to 88.
121
+ - Before every push: flake8, isort and the tests must pass. The pre-push hook
122
+ (`.githooks/pre-push`, on with `git config core.hooksPath .githooks`, once per clone)
123
+ runs them and stops the push otherwise; `git push --no-verify` skips it.
124
+ - Tests live next to the code (`*_test.py`), are plain pytest functions and use `tmp_path`
125
+ and `Commit(immediate=True)` for stores.
126
+
127
+ ## Working agreements
128
+
129
+ - Python >= 3.11. Versions come from git tags via `setuptools_scm` (`2.0.0`);
130
+ `swindl/_version.py` is generated. Don't tag or push unless asked.
131
+ - Report behaviour changes and anything left undone.
132
+ - Known loose ends: `QueryResult.summary` is Dutch text that can't be translated.
swindl-3.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Seecr (Seek You Too B.V.) https://seecr.nl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.