WarningConfirmationMixin
Overview
Gate writes behind an explicit confirmation when they report advisory warnings.
After validation succeeds (so blocking errors have already produced a 400) and before the instance is written, the warnings source is consulted. If it returns warnings and the request has not acknowledged them, a :class:~vueda.core.exceptions.ConfirmationRequired (HTTP 409) is raised, withholding the save. The client surfaces the warnings, the user confirms, and the resubmission carries the warnings digest in the Acknowledge-Warnings header, which matches and lets the write proceed. A changed warning set yields a different digest and re-prompts. The shared gate logic lives in :func:~vueda.core.exceptions.gate_warnings.
Raising before the write means nothing is committed, so this does not depend on the request being wrapped in a transaction.
Warnings sources:
- Single-object
create/update: the serializer'sget_warnings(), consulted inperform_create/perform_update. A serializer withoutget_warnings(including aListSerializerwrapping a Vueda serializer, i.e. bulk writes) is skipped, so warnings on bulk/list saves are not surfaced. destroy,activate, anddeactivate(single and bulk):get_warnings_for_objectfor a single object, andget_warningsfor a bulk request; called byVuedaViewSet.destroyandDeactivateActionViewSetMixin. See their docstrings.
_gate_warnings
Signature
_gate_warnings(self, serializer)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| serializer | yes |
Source
server/vueda/core/viewsets/__init__.py:124
get_warnings
Bulk warnings hook for actions that write without a per-object serializer.
action is the action name string ("destroy", "activate", or "deactivate") and objs is a queryset of the affected instances for a bulk request. Return the per-object {object_id: {field: [messages]}} shape, one entry per warned object keyed by str(pk), so the client can attribute each warning back to its object.
The default calls get_warnings_for_object(action, obj) once per instance in objs and keys each non-empty result by str(obj.pk). Override get_warnings_for_object instead unless bulk needs its own logic (for example a single bulk-optimized query rather than one check per instance).
Signature
get_warnings(self, action, objs)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| action | yes | ||
| objs | yes |
Source
server/vueda/core/viewsets/__init__.py:108
get_warnings_for_object
Single-object warnings hook for actions that write without a per-object serializer.
action is the action name string ("destroy", "activate", or "deactivate") and obj is the single affected instance. Return the aggregate {field: [messages]} shape (the same shape the serializer-level get_warnings() returns; use "non_field_errors" for a warning not tied to a field).
Called directly for a single-object request. The default get_warnings below also calls this once per instance for a bulk request, keying each result by object id, so overriding this hook alone gates both the single-object and bulk forms of action with the same rule -- override get_warnings instead only if bulk needs different or bulk-optimized logic.
The default returns {}, meaning no confirmation is required.
Signature
get_warnings_for_object(self, action, obj)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| action | yes | ||
| obj | yes |
Source
server/vueda/core/viewsets/__init__.py:89
perform_create
Signature
perform_create(self, serializer)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| serializer | yes |
Source
server/vueda/core/viewsets/__init__.py:130
perform_update
Signature
perform_update(self, serializer)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| serializer | yes |
Source
server/vueda/core/viewsets/__init__.py:134
dict {#dict}
dictionary for instance variables
weakref {#weakref}
list of weak references to the object
Source
server/vueda/core/viewsets/__init__.py:63