paperap.models.abstract.meta module


METADATA:

File: meta.py

Project: paperap

Created: 2025-03-07

Version: 0.0.8

Author: Jess Mann Email: jess@jmann.me

Copyright (c) 2025 Jess Mann


LAST MODIFIED:

2025-03-07 By Jess Mann

class paperap.models.abstract.meta.StatusContext(model, new_status)[source]

Bases: object

Context manager for safely updating model status.

model

The model whose status is being updated.

Type:

SomeModel

new_status

The status to set within the context.

Type:

ModelStatus

previous_status

The status before entering the context.

Type:

ModelStatus

Examples

>>> class SomeModel(BaseModel):
...     def perform_update(self):
...         with StatusContext(self, ModelStatus.UPDATING):
...             # Perform an update
Parameters:
  • model (BaseModel)

  • new_status (ModelStatus)

property model: BaseModel

Read-only access to the model.

property new_status: ModelStatus

Read-only access to the new status.

property previous_status: ModelStatus | None

Read-only access to the previous status.

__init__(model, new_status)[source]
Parameters:
  • model (BaseModel)

  • new_status (ModelStatus)

save_lock()[source]

Acquire the save lock

Return type:

None

save_unlock()[source]

Release the save lock, only if this statuscontext previous acquired it.

Return type:

None