際際滷

際際滷Share a Scribd company logo
Viewflow 
internals 
0.6.0 beta
Intro 
Reusable workflow library 
 Django friendly 
 Easy to start 
 Helps to grow 
 Business applications 
 People collaboration
Intro 
Highly technical talk 
Dont panic. Library is only about 3k SLOC 
If anything unclear - ask kmmbvnr@gmail.com
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 
@classmethod 
def activate(cls, flow_task, prev_activation, token): 
def initialize(self, flow_task, task): 
def prepare(self, **data) 
def assign(self, user) 
def start(self) 
 Weaves declarative Flow node 
with Process and Task instance 
def execute(self) def error(self, exc) 
def done(self) 
def activate_next(self)
Parallel task execution and Joins 
Task Token 
 Split Node adds suffix 
 Join Node waits all nodes 
with common prefix 
Short pessimistic locks 
 @flow_view 
 @flow_job 
Optimistic lock with django-fsm on Task 
OR  If your are ok with fails 
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
Viewsite 
Completely 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

More Related Content

Viewflow internals: ~3k sloc explaned

  • 2. Intro Reusable workflow library Django friendly Easy to start Helps to grow Business applications People collaboration
  • 3. Intro Highly technical talk Dont panic. Library is only about 3k SLOC If anything unclear - ask kmmbvnr@gmail.com
  • 4. 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
  • 5. Flow CRUD and Flow Separation Task dependencies graph Boilerplate: Permissions, URLs
  • 6. Models Process/Task tables Multi-table inheritance Abstract base classes
  • 7. Views Function based Views Class based Views URL: <flow_cls>/<process_pk>/<task_name>/<task_pk>
  • 8. Jobs Never miss the broken task Celery out of the box Easy to add another libraries support: rq, huye
  • 9. Gates Workflow patterns support Decide what task should be executed next Easy to add logic by extending class or providing callable
  • 10. Activation @classmethod def activate(cls, flow_task, prev_activation, token): def initialize(self, flow_task, task): def prepare(self, **data) def assign(self, user) def start(self) Weaves declarative Flow node with Process and Task instance def execute(self) def error(self, exc) def done(self) def activate_next(self)
  • 11. Parallel task execution and Joins Task Token Split Node adds suffix Join Node waits all nodes with common prefix Short pessimistic locks @flow_view @flow_job Optimistic lock with django-fsm on Task OR If your are ok with fails Concurrent updates are rare, but:
  • 12. 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
  • 13. Viewsite Completely 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...
  • 14. Thank you $ pip install django-viewflow http://viewflow.io http://github.com/kmmbvnr/django-viewflow/ kmmbvnr@gmail.com