Discussion:
[Erp5-dev] Changing workflow association and restoring document's workflow state
Łukasz Nowak
2007-10-24 10:36:41 UTC
Permalink
Hello,

I have to change some important workflow associations (eg. which
provides simulation_state). I need documents to be moved to same state,
as they had from association from former workflow.

I've experimented a little with removing workflow association from
portal type, and I've seen that in Base_viewHistory it is possible to
fetch history of workflow transitions from old association - even
reindexing object do not remove this history.

I'll go with below scenario:
- create my own workflows (ventis_workflow)
- add special transition from starting state to all possible states
- ventis_workflow will have all states as original_workflow
- remove association from old workflow (original_workflow)
- fetch actual state from original_workflow's history which
hasn't been deleted
- jump into fetched state using transition from ventis_workflow

Is my scenario good enough? I'll try to test it as best as possible,
but any clues are welcome.

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Jérome Perrin
2007-10-24 13:45:05 UTC
Permalink
Post by Łukasz Nowak
Hello,
I have to change some important workflow associations (eg. which
provides simulation_state). I need documents to be moved to same state,
as they had from association from former workflow.
I've experimented a little with removing workflow association from
portal type, and I've seen that in Base_viewHistory it is possible to
fetch history of workflow transitions from old association - even
reindexing object do not remove this history.
- create my own workflows (ventis_workflow)
- add special transition from starting state to all possible states
- ventis_workflow will have all states as original_workflow
- remove association from old workflow (original_workflow)
- fetch actual state from original_workflow's history which
hasn't been deleted
- jump into fetched state using transition from ventis_workflow
Is my scenario good enough? I'll try to test it as best as possible,
but any clues are welcome.
Another way is to directly hack the content of workflow_history on those
documents. It's IMHO the easiest, especially if you want to keep history
details (date, comments).

J?rome
Łukasz Nowak
2007-10-24 13:52:57 UTC
Permalink
Hello,

On 2007-10-24, 15:45:05
J?rome Perrin <jerome at nexedi.com> wrote:

(...)
Post by Jérome Perrin
Another way is to directly hack the content of workflow_history
on those documents. It's IMHO the easiest, especially if you want to
keep history details (date, comments).
Yes, I'd love to. Thanks for idea, I'll try to invoke such "hacks",
but I'm afraid it will require more in depth of understanding :(
Zope/DCWorkFlow.

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Jérome Perrin
2007-10-24 14:43:34 UTC
Permalink
Post by Łukasz Nowak
Hello,
On 2007-10-24, 15:45:05
(...)
Post by Jérome Perrin
Another way is to directly hack the content of workflow_history
on those documents. It's IMHO the easiest, especially if you want to
keep history details (date, comments).
Yes, I'd love to. Thanks for idea, I'll try to invoke such "hacks",
but I'm afraid it will require more in depth of understanding :(
Zope/DCWorkFlow.
Look at workflow_history attribute on document, it's easy to understand
how it's structured (with pprint).
This http://svn.erp5.org/?view=rev&revision=17171 was to change the
state variable name, so it's not exactly the same. If only workflow ID
changed, I think you can simply do:
ob.workflow_history['new_workflow_id'] =\
ob.workflow_history.pop('old_workflow_id')

J?rome
Łukasz Nowak
2007-10-24 14:53:09 UTC
Permalink
Hello,

On 2007-10-24, 16:43:34
J?rome Perrin <jerome at nexedi.com> wrote:

(...)
Post by Jérome Perrin
Look at workflow_history attribute on document, it's easy to
understand how it's structured (with pprint).
This http://svn.erp5.org/?view=rev&revision=17171 was to change the
state variable name, so it's not exactly the same. If only workflow
ob.workflow_history['new_workflow_id'] =\
ob.workflow_history.pop('old_workflow_id')
Hm. Well - yes. Only workflow_id will be changed (for now). So that
solution is great for me. You know, I've overwritten such workflows as
validation_workflow, order_workflow w/o creating mine workflows
(ventis_validation_workflow), etc - so such easy solution will save my
soul.

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Łukasz Nowak
2007-10-26 10:20:24 UTC
Permalink
Hello,

On 2007-10-24, 16:43:34
J?rome Perrin <jerome at nexedi.com> wrote:

(...)
Post by Jérome Perrin
Look at workflow_history attribute on document, it's easy to
understand how it's structured (with pprint).
This http://svn.erp5.org/?view=rev&revision=17171 was to change the
state variable name, so it's not exactly the same. If only workflow
ob.workflow_history['new_workflow_id'] =\
ob.workflow_history.pop('old_workflow_id')
Is attached extension commit-acceptable?

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WorkflowHistoryManage.py
Type: text/x-python
Size: 2843 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20071026/e13088f9/attachment.py>
Łukasz Nowak
2007-10-26 10:26:45 UTC
Permalink
Hello,

On 2007-10-26, 12:20:24
Post by Łukasz Nowak
Hello,
On 2007-10-24, 16:43:34
(...)
Post by Jérome Perrin
Look at workflow_history attribute on document, it's easy to
understand how it's structured (with pprint).
This http://svn.erp5.org/?view=rev&revision=17171 was to change the
state variable name, so it's not exactly the same. If only workflow
ob.workflow_history['new_workflow_id'] =\
ob.workflow_history.pop('old_workflow_id')
Is attached extension commit-acceptable?
It is not! Small typo introduced while refactoring. Attached working
version :)
Post by Łukasz Nowak
Regards,
Regards,
Post by Łukasz Nowak
Luke
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WorkflowHistoryManage.py
Type: text/x-python
Size: 2860 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20071026/942cd48c/attachment.py>
Loading...