Skip to content

core.decorators

Overview

ViewSet action decorators for dry-run support, confirmation gating, and reauthentication.

action

Drop-in replacement for DRF's @action that adds bulk and confirm modes.

bulk=True marks the action as a bulk action, which VuedaRouter also routes at the list URL (no pk) in addition to the detail URL.

confirm=True declares an always-on consequence warning: every mutating request (method not in SAFE_METHODS) is gated through vueda.core.exceptions.gate_warnings before the body runs, with {"non_field_errors": [message]} as the warning set. The message comes from a confirm_message attribute set on the decorated action (my_action.confirm_message = "..." after the definition) and falls back to DEFAULT_CONFIRM_MESSAGE. The unacknowledged first submit therefore always returns a 409 without executing the body; resubmitting with the digest in the Acknowledge-Warnings header runs it. The gate raises regardless of dry-run.

Because confirm=True gates before the body, it suits input-less consequence actions: any body-level validation 400 would only surface after the 409 is acknowledged. Actions with input should instead call gate_warnings(request, ...) explicitly after serializer.is_valid(raise_exception=True) so 400s precede the 409.

Signature

action(methods, detail, bulk, confirm, url_path, url_name, kwargs)

Parameters

NameTypeRequiredDescription
methodsyes
detailyes
bulkyes
confirmyes
url_pathyes
url_nameyes
kwargsyes

Source

server/vueda/core/decorators.py:31

DEFAULT_CONFIRM_MESSAGE

Warning text used by @action(confirm=True) when the action sets no confirm_message.

Source

server/vueda/core/decorators.py

Documents matching: server v3.0.0a1.post1client v3.0.0-alpha.2