Action-based request handling and workflow engine for ViUR modules.
Project description
viur-actions
Action-based request handling for ViUR modules.
Features
@actiondecorator andActionModulemixin- Class-init hook wiring (
can<X>/on<X>/then<X>/<X>Skel), falling back to the suffix-less defaults (can/on/then/skel) - Envelope-v2 via a versioned renderer — mounted under
/json/v2/·/vi/v2/byinstall(), selected per-URL. No monkey-patch, no global switch. By default the unversioned/json/·/vi/follow the newest version (v2); passalias_to_newest=Falseto keep them on v1.
Multi-step workflows (drafts, sliding TTL, optimistic locking, cleanup task)
live in the sibling
viur-workflow package. See
CHANGELOG.md for the running summary.
Requirements
- Python ≥ 3.12
- viur-core ≥ 3.8, < 4
Install
pip install spltz-viur-actions
Quick taste
Serve the envelope by mounting the versioned renderer after setup():
from viur.core import setup
import viur.actions
import modules
app = setup(modules)
viur.actions.install() # mounts /json/v2/… + /vi/v2/…; unversioned /json/ · /vi/ follow v2
Declare actions and hooks on a module:
from viur.core.prototypes import List
from viur.actions import action, ActionModule
class Example(ActionModule, List):
@action
def edit(self, key, **kwargs):
...
# Fallback hooks — every action without specific hooks lands here.
# (No `skel`: on a SkelModule viur-core's own `skel` is the base
# skeleton factory, so defining one here would shadow it and recurse.)
def can(self, skel): ...
def on(self, skel): ...
def then(self, skel): ...
# Action-specific overrides — picked up automatically:
def canEdit(self, skel): ...
def editSkel(self): ...
The class-init wiring (__init_subclass__) checks at class definition time
which hooks the module provides, and resolves missing ones to the
suffix-less default chain. Lookup at runtime is constant-time.
Note: these hooks are resolved for your own
@actionbodies (via theruntimehelpers). viur-core's built-inview/edit/… still call their owncanView/onEdited/… directly —canis not a global policy for them.
Development
Two test layers, run separately:
Unit (fast, mocked) — tests/, 100 % coverage gate:
git clone https://github.com/sprengplatz/viur-actions
cd viur-actions
pip install --no-deps -e .
pip install pytest pytest-cov 'coverage[toml]' 'spltz-viur-light-mock>=0.2.0'
pytest # 100% coverage required
spltz-viur-light-mock provides the viur.core.* stand-ins so these run without
the App Engine stack.
Integration (real core) — integration/, no coverage gate:
pip install "viur-core>=3.8,<4" rsa pytest # NOT spltz-viur-light-mock
pip install --no-deps -e .
python -m pytest -c integration/pytest.ini integration
Runs the envelope + signature-parity tests against the real framework — the layer that catches mock-vs-core drift. See integration/README.md.
Coverage policy. The 100 % gate applies to the unit layer only. The integration layer runs without a coverage requirement — a coverage target there would pressure mocking the very framework it exists to exercise.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spltz_viur_actions-0.2.1.tar.gz.
File metadata
- Download URL: spltz_viur_actions-0.2.1.tar.gz
- Upload date:
- Size: 32.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00d0f986955050ce1d2b03192220df257a8dbca2aa287ac351abd055e80ad139
|
|
| MD5 |
b7ad5c81dd356bb714c21efa6d4270ad
|
|
| BLAKE2b-256 |
667dc61c0c0c5604d698e9619bd1b1742857ef61d0b42386a32f623530f140a8
|
Provenance
The following attestation bundles were made for spltz_viur_actions-0.2.1.tar.gz:
Publisher:
release.yml on sprengplatz/viur-actions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spltz_viur_actions-0.2.1.tar.gz -
Subject digest:
00d0f986955050ce1d2b03192220df257a8dbca2aa287ac351abd055e80ad139 - Sigstore transparency entry: 2124674454
- Sigstore integration time:
-
Permalink:
sprengplatz/viur-actions@5e90e8dceb1a7409523e926c5293ab0b59b6300b -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/sprengplatz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e90e8dceb1a7409523e926c5293ab0b59b6300b -
Trigger Event:
push
-
Statement type:
File details
Details for the file spltz_viur_actions-0.2.1-py3-none-any.whl.
File metadata
- Download URL: spltz_viur_actions-0.2.1-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cda8744254069a89a179a2c182911f3b3ddec0fa1a83efabe40e19ac4b73073
|
|
| MD5 |
aee329bd2bd01d003784e3111c55a4ff
|
|
| BLAKE2b-256 |
8f062db6b80d317315198c1afa73352f0131ad3cd1839fe924e57df9c597b7d8
|
Provenance
The following attestation bundles were made for spltz_viur_actions-0.2.1-py3-none-any.whl:
Publisher:
release.yml on sprengplatz/viur-actions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spltz_viur_actions-0.2.1-py3-none-any.whl -
Subject digest:
6cda8744254069a89a179a2c182911f3b3ddec0fa1a83efabe40e19ac4b73073 - Sigstore transparency entry: 2124674487
- Sigstore integration time:
-
Permalink:
sprengplatz/viur-actions@5e90e8dceb1a7409523e926c5293ab0b59b6300b -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/sprengplatz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e90e8dceb1a7409523e926c5293ab0b59b6300b -
Trigger Event:
push
-
Statement type: