Skip to content

history.revision

Overview

The per-object revision token.

object_revision answers one question: is the copy of this object I hold still the current one. It is the object's newest event identifier, and it shares the form of the identifiers the history response publishes, so a client compares the token it holds against an event's own identifier directly rather than learning a second concept.

Nothing enforces the token on write. It exists so a later conflict-detection feature has a primitive to build on.

Classes

annotate_object_revision

Annotate the newest event id for each row. A no-op for a model without history.

Applied where the token is serialized rather than on every queryset, following annotate_formatted_name. The subquery matches on the event table's indexed object column.

Signature

annotate_object_revision(queryset)

Parameters

NameTypeRequiredDescription
querysetyes

Source

server/vueda/history/revision.py:41

is_tracked

Whether history recorded an event model for this model.

pghistory sets pgh_event_model on a model it tracks, so this answers the model's history policy as it actually resolved rather than as it was declared. A proxy inherits the concrete model's event model, which is where its writes are recorded.

Signature

is_tracked(model)

Parameters

NameTypeRequiredDescription
modelyes

Returns

<class 'bool'>

Source

server/vueda/history/revision.py:31

object_revision

Return instance's newest event identifier, or None when it has none.

annotate_object_revision is the cheaper path for a queryset on its way through a serializer. This one serves a caller holding one instance, such as a response reporting the revision of the row it just wrote. It costs one query.

Signature

object_revision(instance)

Parameters

NameTypeRequiredDescription
instanceyes

Source

server/vueda/history/revision.py:64

Source

server/vueda/history/revision.py

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