# State Transition System (STS) for Django
[State Transition Systems][1] have less constraints than Finite State
Automata, and can be molded into various use cases.
The core components include:
- State
- Event
- Transition
- System
**Events** cause a **transition** from some **state** (or none if this is the
first transition) to a new state for a given **system**.
The API supports defining _immediate_ transitions and _long-running_
transitions. Now, for a riveting example..
```python
system = System(name='Example 1')
system.save()
# Immediate transition.. event => state
system.transition('Open Door', 'Door Opened')
# 'Long-running' transitions.. event happens
system.start_transition('Close Door Slowly')
# Time passes..
time.sleep(2)
# The resulting state..
system.end_transition('Door Closed')
```
`System`s can also be associated directly to an object using Django's
ContentType framework.
```python
door = Door.objects.get(name='Door #1')
system = System(content_object=door)
# ...
```
This enables bringing in django-sts to an existing model to begin tracking
states of objects.
If even comes with an abstract `STSModel` that augments a model with the above
methods for seamless integration (it does not add any model fields):
```python
class Door(STSModel):
name = models.CharField(max_length=20)
door = Door()
door.save()
door.transition('Close Door', 'Door Closed')
```
The library leaves it up to the application to implement the constraints of a
finite state automata/machine.
[1]: http://en.wikipedia.org/wiki/State_transition_system
[State Transition Systems][1] have less constraints than Finite State
Automata, and can be molded into various use cases.
The core components include:
- State
- Event
- Transition
- System
**Events** cause a **transition** from some **state** (or none if this is the
first transition) to a new state for a given **system**.
The API supports defining _immediate_ transitions and _long-running_
transitions. Now, for a riveting example..
```python
system = System(name='Example 1')
system.save()
# Immediate transition.. event => state
system.transition('Open Door', 'Door Opened')
# 'Long-running' transitions.. event happens
system.start_transition('Close Door Slowly')
# Time passes..
time.sleep(2)
# The resulting state..
system.end_transition('Door Closed')
```
`System`s can also be associated directly to an object using Django's
ContentType framework.
```python
door = Door.objects.get(name='Door #1')
system = System(content_object=door)
# ...
```
This enables bringing in django-sts to an existing model to begin tracking
states of objects.
If even comes with an abstract `STSModel` that augments a model with the above
methods for seamless integration (it does not add any model fields):
```python
class Door(STSModel):
name = models.CharField(max_length=20)
door = Door()
door.save()
door.transition('Close Door', 'Door Closed')
```
The library leaves it up to the application to implement the constraints of a
finite state automata/machine.
[1]: http://en.wikipedia.org/wiki/State_transition_system
Metadata
Release files for django-sts 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-sts-0.1.tar.gz | 4.9 kB | Details |
Release files / django-sts-0.1.tar.gz
| Download URL | django-sts-0.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2360b9ac516dd1f0a425fa1eab8e27720579301c84084b63306d3fc657c2ed9
|
|
BLAKE2b-256 checksum How to use checksums |
45ca63327a0d89bd83bb43cfcae228e76b9979df8f2544fa5f9b34fe92c07dea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |