Skip to main content

Automatic revision tracking and rollback for ViUR skeletons.

Project description

viur-revision

Automatic revision tracking and rollback for ViUR skeletons.

Tests Docs License: MIT

What it does

viur-revision snapshots the pre-write state of any tracked skeleton into a companion datastore kind (<kind>_revision) on every write. Each revision entity carries:

  • a verbatim copy of all original entity properties
  • origin_key — the original entity's key
  • revision_index — monotonically increasing counter per origin
  • revision_date — UTC timestamp of the snapshot
  • revision_change_list — bone names that changed in this write

The package adds endpoints to list, view, restore, and delete revisions, plus a tiered retention task that thins out the history over time.

Requirements

  • Python ≥ 3.12
  • viur-core ≥ 3.7, < 4

Install

pip install spltz-viur-revision

Usage

1. Make a skeleton track revisions

from viur.revision import RevisionAbstractSkel

class ExampleSkel(RevisionAbstractSkel, Skeleton):
    # Track every write (default):
    pass

Or only react to changes on specific bones:

class ExampleSkel(RevisionAbstractSkel, Skeleton):
    revision_fields = ["title", "body"]

2. Expose revision endpoints on the module

from viur.revision import RevisionModule

class Example(RevisionModule, List):
    ...

This adds:

  • GET /<module>/list_revision?key=<entity-key>
  • GET /<module>/view_revision?key=<entity-key>&version=<n|latest>
  • POST /<module>/apply_revision (skey-protected)
  • POST /<module>/delete_revision (skey-protected)
  • GET /<module>/cleanup_revisions_now (manual retention run)

All endpoints require either the root right or <moduleName>-manage.

3. Retention

A daily PeriodicTask thins history per origin_key:

Age Retention
< 24h keep all
1d–7d 1 per hour (latest)
7d–30d 1 per day (latest)
> 30d 1 per week (latest)

Documentation

Full reference at sprengplatz.github.io/viur-revision.

Development

git clone https://github.com/sprengplatz/viur-revision
cd viur-revision
pip install -e ".[dev]"
pytest                  # 100% coverage required
mkdocs serve            # docs at http://localhost:8000

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spltz_viur_revision-0.1.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spltz_viur_revision-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file spltz_viur_revision-0.1.0.tar.gz.

File metadata

  • Download URL: spltz_viur_revision-0.1.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spltz_viur_revision-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9f48ecde6866d3760028ef39eb63b5ebd83543a7c4a2f8abc1a0969a384a156e
MD5 e34900fcb457e41300a4beb58f359d38
BLAKE2b-256 fa74a4ab4ad8e8c8c8ed4c0db1003421572719fc5ffcc40436b95dda5f14dd08

See more details on using hashes here.

Provenance

The following attestation bundles were made for spltz_viur_revision-0.1.0.tar.gz:

Publisher: release.yml on sprengplatz/viur-revision

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spltz_viur_revision-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spltz_viur_revision-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2309451a513c2b811e2e83eec5b20e3420c2c6f2bcfa9a3d2df085ae2c09ebf3
MD5 7772332934cc9a3e8f3a09ac81a1fb84
BLAKE2b-256 dffedd1260434a986001594740549991632c2cbec8e20af1f41cbcc527e36969

See more details on using hashes here.

Provenance

The following attestation bundles were made for spltz_viur_revision-0.1.0-py3-none-any.whl:

Publisher: release.yml on sprengplatz/viur-revision

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page