[Erp5-dev] Consistency checker in workflows - proposal

Łukasz Nowak lukasz.nowak at ventis.com.pl
Tue Apr 17 16:09:33 CEST 2007


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...''





More information about the Erp5-dev mailing list