This project has been archived by its maintainers, and is no longer receiving any updates.
roughrider.workflow
This package allows to define workflows that consist of a set of states, transitions between the states. Actions that activate the transitions can be guarded by constraints.
Example
from roughrider.predicate import ConstraintError, Validator, Or
from roughrider.workflow.components import Action, Transition, Transitions
from roughrider.workflow.workflow import (
WorkflowItem, WorkflowState, Workflow)
class Document:
state = None
body = ""
class RoleValidator(Validator):
def __init__(self, role):
self.role = role
def __call__(self, item, role=None, **namespace):
if role != self.role:
raise ConstraintError(
message=f'Unauthorized. Missing the `{role}` role.')
class PublicationWorkflow(Workflow):
class wrapper(WorkflowItem):
@property
def state(self):
return self.workflow.get(self.item.state)
@state.setter
def state(self, state):
self.item.state = state.name
class states(WorkflowState):
draft = 'Draft'
published = 'Published'
submitted = 'Submitted'
transitions = Transitions((
Transition(
origin=states.draft,
target=states.published,
action=Action(
'Publish',
constraints=[RoleValidator('publisher')]
)
),
Transition(
origin=states.published,
target=states.draft,
action=Action(
'Retract',
constraints=[
Or((RoleValidator('owner'),
RoleValidator('publisher')))
]
)
),
Transition(
origin=states.draft,
target=states.submitted,
action=Action(
'Submit',
constraints=[RoleValidator('owner')],
)
),
Transition(
origin=states.submitted,
target=states.published,
action=Action(
'Publish',
constraints=[RoleValidator('publisher')],
)
)
))
workflow = PublicationWorkflow('draft') # initial state
item = Document()
workflow_item = workflow(item, role='owner')
workflow_item.transition_to(PublicationWorkflow.states.submitted)
CHANGES
0.2 (2021-10-21)
Updating to use roughrider.predicate >= 0.3.1
0.1 (2021-10-09)
Initial release.
Metadata
Release files for roughrider.workflow 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| roughrider.workflow-0.2.tar.gz | 13.0 kB | Without provenance | Details for roughrider.workflow-0.2.tar.gz |
Release files / roughrider.workflow-0.2.tar.gz
| Download URL | roughrider.workflow-0.2.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
585765d091b7cad7872bb8dafb73beb9e5c83b415c7b62808ef734094a709a53
|
|
BLAKE2b-256 checksum How to use checksums |
bd7735806ce8be47cd78fdaf302757eee1fd6a7046c8a003b4d31aae1da73a83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Security for roughrider.workflow 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.