Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3694702
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:31:42+00:00 2026-05-19T04:31:42+00:00

I’m working to implement a workflow engine into my project and the main purpose

  • 0

I’m working to implement a workflow engine into my project and the main purpose of my attempt is to create a portable app. Something, I would be able to place into any other project in the future and then attach workflows to different models in my projects and get it to work.

I tried to think of an approach but it doesn’t seem to be the perfect setup. I thought of creating an workflow app inside my project, attach two kind of models, some will contain the setup of a the workflow (workflow, steps, actions) and other models will contain the instances/transactions.

Below is my workflow/models.py

from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
import signals


################################
#   Workflow engine models
################################

class Signal_Listener(models.Model):
    LISTENING_ON = (
    ('I', 'INSERT'),
    ('U', 'UPDATE'),
    ('D', 'DELETE'),
    ('S', 'SELECT'),
    ('A', 'ANY QUERY'),
    ('L', 'ANY DDL'),
    )

    table_name = models.CharField(max_length=100)
    listening_to = models.CharField(max_length=1, choices=LISTENING_ON)

    class Meta:
        unique_together = (("table_name", "listening_to"),)

    def __unicode__(self):
        return '%s - %s' % (self.table_name, self.listening_to)

class Action(models.Model):
    ACTION_TYPE_CHOICES = (
    ('P', 'Python Script'   ),
    ('C', 'Class name'      ),
    )
    name = models.CharField(max_length=100)
    action_type = models.CharField(max_length=1, choices=ACTION_TYPE_CHOICES)
    audit_obj = generic.GenericRelation('core.Audit', editable=False)

class Steps(models.Model):
    sequence = models.IntegerField() 
    Action = models.ForeignKey(Action)
    Signal_Listener = models.ForeignKey(Signal_Listener)

class Process(models.Model):
## TODO: Document
# Processes class is used to store information about the process itself.
# Or in another word, the workflow name.
    WF_TYPE_LIST = (
    ('P', 'Python-API'),
    )

    name = models.CharField(max_length=30)
    is_active = models.BooleanField()
    wf_type = models.CharField(max_length=1, choices=WF_TYPE_LIST)
    audit_obj = generic.GenericRelation('core.Audit', editable=False)
    listening_to = models.ForeignKey(Steps)



################################
#   Workflow transactions models
################################

class Instance(models.Model):
##  TODO: Document
# Re
    INSTANCE_STATUS = (
    ('I', 'In Progress' ),
    ('C', 'Cancelled'   ),
    ('A', 'Archived'     ), # Old completed tasks can be archived
    ('P', 'Pending'     ),
    ('O', 'Completed'   )
    )

    id = models.CharField(max_length=200, primary_key=True)
    status = models.CharField(max_length=1, choices=INSTANCE_STATUS, db_index=True)
    audit_obj = generic.GenericRelation('core.Audit', editable=False)

    def save(self, *args, **kwargs):
    # on new records generate a new uuid
        if self.id is None or self.id.__len__() is 0:
            import uuid

            self.id = uuid.uuid4().__str__()
        super(Instances, self).save(*args, **kwargs)

class Task(models.Model):
    TASK_STATUS = (
    ('S', 'Assigned'    ),
    ('I', 'In Progress' ),
    ('P', 'Pending'     ),
    ('C', 'Cancelled'   ),
    ('A', 'Archived'    ), # Old completed tasks can be archived
    ('O', 'Completed'   )
    )
    name = models.CharField(max_length=100)
    instance = models.ForeignKey(Instance)
    status = models.CharField(max_length=1, choices=TASK_STATUS)
    bio = models.CharField(max_length=100)
    audit_obj = generic.GenericRelation('core.Audit', editable=False)

and I also have a workflow/signals.py

    """
        Workflow Signals
            Will be used to monitor all inserts, update, delete or select statements
            If an action is attached to that particular table, it will be inserted Celery-Tasks distribution.
    """
    from django.db.models.signals import post_save, post_delete
    from django.core.cache import cache


    def workflow_post_init_listener(sender, **kwargs):
        try:

            if cache.get('wf_listner_cache_%s' % kwargs['instance']._meta.db_table):
                pass
            else:
                record = 'Signal_Listener'.objects.get(table_name__exact=kwargs['instance']._meta.db_table)
# am not sure what to do next!
        except 'Signal_Listener'.DoesNotExist:
            # TODO: Error logging
            pass

    post_save.connect(workflow_post_init_listener, dispatch_uid="workflow.models.listener.save")

I think my model design might need to be enhanced as well. I could use in several scenarios and I was thinking to start with the approval cycle, for example, I could insert the table_name/model_name in signal_listener to monitor for new inserts. If so, I will trigger a particular workflow.

As for actions, I do understand that actions will require to be developed. Maybe i will need to create an action folder under workflow app, put each action in a class. Each will do a particular task of sending emails, archiving, update database value..etc

If am reinventing the wheel and if there is such thing that has been developed already, any one can suggest, I would be more than happy to go through it.

Best regards,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:31:43+00:00Added an answer on May 19, 2026 at 4:31 am

    For example you can have a look for zope.wfmc (http://pypi.python.org/pypi/zope.wfmc) : this is an implementation of a Workflow-Management Coalition
    Workflow that can be defined on XPDL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.