viewflow internals: ~3k sloc explaned
DESCRIPTION
Viewflow Internals http://viewflow.ioTRANSCRIPT
![Page 1: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/1.jpg)
Viewflow internals0.6.0 beta
![Page 2: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/2.jpg)
Intro
➔ Django friendly➔ Easy to start➔ Helps to grow
➔ Business applications➔ People collaboration
Reusable workflow library
![Page 3: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/3.jpg)
Intro
Highly technical talk
If anything unclear - ask [email protected]
Don’t panic. Library is only about 3k SLOC
![Page 4: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/4.jpg)
Intro
➔ Flow◆ Nodes◆ This object
➔ Models➔ Nodes
◆ Views◆ Jobs◆ Gates
➔ Activation◆ Livecycle
➔ Parallel tasks execution◆ Token◆ Locking
➔ Error handling◆ Activation context
➔ Viewsite◆ Forms
Viewflow internals
![Page 5: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/5.jpg)
Flow
➔ CRUD and Flow Separation➔ Task dependencies graph➔ Boilerplate: Permissions, URLs
![Page 6: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/6.jpg)
Models
➔ Process/Task tables➔ Multi-table inheritance➔ Abstract base classes
![Page 7: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/7.jpg)
Views
➔ Function based Views ➔ Class based Views
URL: <flow_cls>/<process_pk>/<task_name>/<task_pk>
![Page 8: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/8.jpg)
Jobs➔ Never miss the broken task➔ Celery out of the box➔ Easy to add another libraries support:
rq, huye
![Page 9: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/9.jpg)
Gates
➔ Workflow patterns support➔ Decide what task should be executed next➔ Easy to add logic by extending class or
providing callable
![Page 10: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/10.jpg)
Activation
def prepare(self, **data)
@classmethod
def activate(cls, flow_task, prev_activation, token):
def initialize(self, flow_task, task):
def assign(self, user)
def start(self)
def execute(self) def error(self, exc)
def done(self)
def activate_next(self)
➔ Weaves declarative Flow node with Process and Task instance
![Page 11: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/11.jpg)
Parallel task execution and Joins
➔ Split Node adds suffix➔ Join Node waits all nodes
with common prefix
Task Token
Short pessimistic locks➔ @flow_view➔ @flow_job
Optimistic lock with django-fsm on Task ➔ If your are ok with failsOR
Concurrent updates are rare, but:
![Page 12: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/12.jpg)
Error handling
View Jobs
➔ Any exception in subsequent task activation would rollback whole transaction.
➔ View task still available for user second try
➔ Job results committed immediately as job completes.
➔ Any exception in subsequent tasks activations would save subsequent task in error state.
Could be customized by providing custom Activation class
![Page 13: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/13.jpg)
ViewsiteCompletely optional, but you will like it
➔ Admin like speed for interface development➔ Works with your Views➔ Ready for end user➔ Forms layouts, dynamic formsets, bootstrap
More in next videos...
![Page 14: Viewflow internals: ~3k sloc explaned](https://reader036.vdocument.in/reader036/viewer/2022081511/55646a09d8b42acd408b51be/html5/thumbnails/14.jpg)
Thank you
$ pip install django-viewflow
http://viewflow.io
http://github.com/kmmbvnr/django-viewflow/