Post on 26-May-2015
description
transcript
Viewflow internals0.6.0 beta
Intro
➔ Django friendly➔ Easy to start➔ Helps to grow
➔ Business applications➔ People collaboration
Reusable workflow library
Intro
Highly technical talk
If anything unclear - ask kmmbvnr@gmail.com
Don’t panic. Library is only about 3k SLOC
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
Flow
➔ CRUD and Flow Separation➔ Task dependencies graph➔ Boilerplate: Permissions, URLs
Models
➔ Process/Task tables➔ Multi-table inheritance➔ Abstract base classes
Views
➔ Function based Views ➔ Class based Views
URL: <flow_cls>/<process_pk>/<task_name>/<task_pk>
Jobs➔ Never miss the broken task➔ Celery out of the box➔ Easy to add another libraries support:
rq, huye
Gates
➔ Workflow patterns support➔ Decide what task should be executed next➔ Easy to add logic by extending class or
providing callable
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
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:
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
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...
Thank you
$ pip install django-viewflow
http://viewflow.io
http://github.com/kmmbvnr/django-viewflow/
kmmbvnr@gmail.com