[Erp5-report] r27964 - in /erp5/trunk/products/ERP5Type: Base.py tests/testERP5Type.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Jul 6 11:39:08 CEST 2009
Author: jm
Date: Mon Jul 6 11:39:00 2009
New Revision: 27964
URL: http://svn.erp5.org?rev=27964&view=rev
Log:
When executing a workflow method, raise if the transition does not exist from the current state, or if the guard rejects it.
Modified:
erp5/trunk/products/ERP5Type/Base.py
erp5/trunk/products/ERP5Type/tests/testERP5Type.py
Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=27964&r1=27963&r2=27964&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Base.py [utf8] Mon Jul 6 11:39:00 2009
@@ -207,8 +207,9 @@
if candidate_workflow.isWorkflowMethodSupported(instance, transition_id):
valid_list.append(transition_id)
elif candidate_workflow.__class__.__name__ == 'DCWorkflowDefinition':
- # XXX Do not raise for the moment as ERP5 is not ready.
- #raise UnsupportedWorkflowMethod(instance, wf_id, transition_id)
+ raise UnsupportedWorkflowMethod(instance, wf_id, transition_id)
+ # XXX Keep the log for projects that needs to comment out
+ # the previous line.
LOG("WorkflowMethod.__call__", ERROR,
"Transition %s/%s on %r is ignored. Current state is %r."
% (wf_id, transition_id, instance,
Modified: erp5/trunk/products/ERP5Type/tests/testERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testERP5Type.py?rev=27964&r1=27963&r2=27964&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testERP5Type.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testERP5Type.py [utf8] Mon Jul 6 11:39:00 2009
@@ -38,6 +38,7 @@
from zLOG import LOG, INFO
from Products.CMFCore.Expression import Expression
from Products.CMFCore.tests.base.testcase import LogInterceptor
+from Products.CMFCore.WorkflowCore import WorkflowException
from Products.ERP5Type.Base import _aq_reset
from Products.ERP5Type.tests.utils import installRealClassTool
from Products.ERP5Type.Utils import removeLocalPropertySheet
@@ -2613,6 +2614,15 @@
address.manage_permission(permission, roles=(), acquire=0)
check(0)
+ def test_unsupportedTransitionRaises(self):
+ """
+ Check that an object must be in the expected state in order to execute
+ a transition.
+ """
+ person = self.getPersonModule().newContent(portal_type='Person')
+ person.validate()
+ self.assertRaises(WorkflowException, person.validate)
+
class TestAccessControl(ERP5TypeTestCase):
# Isolate test in a dedicaced class in order not to break other tests
# when this one fails.
More information about the Erp5-report
mailing list