pymap.versioned¶
- class pymap.versioned.VersionedT¶
Type variable for versioned objects.
alias of TypeVar(‘VersionedT’, bound=
Versioned[Any])
- class pymap.versioned.EntityTagT¶
Type variable for versioned object entity tags.
alias of TypeVar(‘EntityTagT’)
- class pymap.versioned.Versioned[source]¶
This simple base class defines objects that supports “versioning” using entity tags.
The
entity_tagof an object represents the current object andprevious_entity_tagrepresents the object that it is intended to replace. A versioned object then provides optimistic locking by preventing replacement of an object other than the one it was intended to replace.In a linear chain of objects and their replacements, the first object in the chain should have a
previous_entity_tagofNone, and every subsequent object should have aprevious_entity_tagequal to theentity_tagof the object before it.- REPLACE_ANY: ClassVar[Any] = <object object>¶
A special marker for
previous_entity_tagindicating that any previous object may be replaced.
- abstract property entity_tag: EntityTagT¶
Represents the current version of the object.
- abstract property previous_entity_tag: EntityTagT | None¶
Represents the version of the object it is intended to replace.
- can_replace(previous)[source]¶
Check if this object can replace the previous object.
- Parameters:
previous (VersionedT | None) – The object to be replaced, if any.
self (VersionedT)
- Return type:
- abstract classmethod new_entity_tag()[source]¶
Generate a new random value for
entity_tag.- Return type: