2

I'd like to use SpiffWorkflow in conjunction with Django, but apparently SpiffWorkflow can only serialize its states to JSON and XML:

https://github.com/knipknap/SpiffWorkflow/tree/master/SpiffWorkflow/storage

SpiffWorkflow allows serialization of running workflow, so I could store it essentially as a byte stream somewhere (either in filesystem or in Django's DB). But that deprives me of all the advantages of Django.

Is there some way of mapping dictionary or deserialized JSON structure onto objects that Django can use as a regular Django object (stored by Django ORM in a database)? Would writing such a Django backend for SpiffWorkflow/its workflow's JSON representation be complicated? I'm asking because I have basically no experience in Django.

LetMeSOThat4U
  • 6,470
  • 10
  • 53
  • 93
  • Hi, I am facing the same issue here. How is your project going? – Jerry Meng Oct 06 '14 at 22:10
  • @JerryMeng: no progress unfortunately, it seems strange that workflow authors give little thought to workflow persistence and querying workflow states given how prevalent are web frameworks with some sort of RDBMS backend, but there it is. – LetMeSOThat4U Oct 07 '14 at 11:38
  • Well, after some dig into this package, I just realize what you mean. I try to implement the db backend to associate with this package. I mean if I cannot save the workflow tree and state somewhere, then I will lose the track of my workflow. After all not all the task can be done instantly. I cannot save all the info in session, otherwise, as long as I restart the server, everything just gone. I suspect my next step is to design the corresponding db schema for this package. – Jerry Meng Oct 08 '14 at 15:42
  • There are plenty of ready to use django workflow packages that have no issues with state storage - http://stackoverflow.com/questions/6795328/workflow-frameworks-for-django/25717038#25717038 – kmmbvnr Feb 16 '15 at 06:58

1 Answers1

1

You can use NoSQL as database backend instead of a RDBMS. I suggest MongoDB as it uses JSON notation to store data and could be used in Django projects using mongodb-engine. MongoDB is schemaless (read MongoDB website article about being schemaless). You may store your data with any structure you want and change it later on the fly.

There are also other NoSQL backends supported by Django like Redis, Elasticsearch and etc. and you can take a look at them to find the best fit for your special needs.

Mazdak B.
  • 66
  • 5
  • django / postgres can function a bit like NoSQL db with the json field, https://docs.djangoproject.com/en/3.1/ref/contrib/postgres/fields/#jsonfield – yvess Sep 14 '20 at 07:48