Discussion:
[Erp5-dev] Consistency checker in workflows - proposal
Łukasz Nowak
2007-04-17 14:09:33 UTC
Permalink
Hello,

In Ventis we are modifying workflows very often. Many modifications are
related with checkConsistency of portal types associated with eg.
validation_workflow - Product, Component, Service, Bank Account, etc.

I've extended checkConsistency script with such snippet:

== snip ==
check_result = object.checkConsistency()

checker_name = '%
s_validation_workflow_checkConsistency'%(object.getPortalType().replace(' ',''),)

try:
check_result.extend(getattr(object,checker_name,None)())
except TypeError,e:
pass

if len(check_result) > 0:
== snip ==

It allows me to define script with name
Product_validation_workflow_checkConsistency, which returns list of
failed messages and put it into BT - without further modification of
workflow. Same might be applied to other workflows, in more generic case
extended with transition name, eg.
SaleInvoiceTransaction_accounting_workflow_stop_action_checkConsistency
(to achieve that script generator in workflow have to be extended, but
it's not so hard).

Advantages:
- developer is able to check scripts easily against existing objects
without invoking workflow action, which makes developing and debugging
easier
- scripts are well named, easy to find, and might is put into business
template
- such change is backward compatible, as scripts are optional
- scripts can be put into chains, eg. if Product/Component have many
related parts, could be moved to another script, which only extend
type-specific error list

Disadvantages:
- I count on you ;)

Q: Is it good idea?
Q: How to made transition-based script invocation?
Q: Would it be better to do it as "low-level" DCWorkflow extension?

Thanks,
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...''
Jérôme Perrin
2007-04-24 07:45:11 UTC
Permalink
Post by Łukasz Nowak
Hello,
In Ventis we are modifying workflows very often. Many modifications are
related with checkConsistency of portal types associated with eg.
validation_workflow - Product, Component, Service, Bank Account, etc.
checkConsistency is already extensible by adding a property sheet with
Constraints to the portal type, without any need to modify the workflow.
As far as I know, everything proposed here can be done with Constraints.

J?rome
Łukasz Nowak
2007-05-08 09:06:44 UTC
Permalink
Hello,
Post by Jérôme Perrin
Post by Łukasz Nowak
Hello,
(...)
Post by Jérôme Perrin
checkConsistency is already extensible by adding a property sheet with
Constraints to the portal type, without any need to modify the workflow.
As far as I know, everything proposed here can be done with Constraints.
Huh... You're right. I've reinvented the wheel...again ;)
Is there any documentation for Constraints? Anything what I found are
some examples in Constraints and PropertySheets - and following examples
is not always good idea tm.

Might it be good to move
http://cps.erp5.org/workspaces/project/guide/consistency/view
to ERP5 wiki? (I've forgotten to check old site before, my fail).

Thanks for a clue,
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...''
Jérôme Perrin
2007-05-09 15:51:15 UTC
Permalink
Post by Łukasz Nowak
Is there any documentation for Constraints?
Few month ago, I wrote this:
http://svn.erp5.org/erp5/trunk/products/ERP5Type/Interface/Constraint.py?view=markup
the API changed a bit since; checkConsistency no longer return tuples, but
ConsistencyMessage instances. As far as I know, the question of
internationalization of those messages is still open.

J?rome

Loading...