[Zope-CMF] DCWorkflow, Copy and Paste CMF Instance, Extra Cruft on your History

Alan Runyan runyaga@runyaga.com
Sun, 6 Jan 2002 00:44:25 -0600


well.. after much ballyhoo'ing.  kapil helped me through it.  and I'm all
the wiser on how DCWorkflow works so here it is.

Quick Answer:
  When I was copying and pasting my CMF instance, I was getting 2 extra
histories on my content objects (making them go back to their initial
state).  I use a external method to grab the workflow_history attribute
(which is a mapping) then got the history list and whacked off the offending
2 histories, viola.  something like:
    wf_history=o.workflow_history
    wf_list=wf_history['publish2website'] #publish2website is the name of my
DCWorkflow
    wf_list=wf_list[:-2]
    o.workflow_history['publish2website']=wf_list

viola, object is back to normal.

A Tad Longer Answer and Solution:
  It seems that objects that are participating in portal_workflow will get
caught up in the mange_beforeDelete and manage_afterAdd events.  I dont know
what is happening but the Workflow I assume just assume's well, something
has happened in the workflow and resets to the initial state.
  If you have no portal_workflow, there is no observer to update the content
objects.  so what I did was cut/paste the portal_workflow tool to a empty
CMF instance.  and then copy and pasted the CMF instance.  my objects no
longer had the two transactions attached to their workflow_history.
  When I made sure verything was honkey-dorey I cut/pasted the
portal_workflow tool back into both the new and old CMF instances ;)
  workflow_history is a PeristentMapping, keyed by workflow_id's.  these
values are the history lists.  these are workflow states.  the last workflow
state is the most recent.