[Erp5-report] r42258 jm - in /erp5/trunk: bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_...

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Jan 12 12:39:31 CET 2011


Author: jm
Date: Wed Jan 12 12:39:31 2011
New Revision: 42258

URL: http://svn.erp5.org?rev=42258&view=rev
Log:
Some review of causality workflow

- delaying 'updateCausalityState' instead of 'calculate'
- make sure 'updateCausalityState' depends on all related simulation movements
- do not process 'updateCausalityState' as long as there remains
  'Delivery_calculate' activities

This fixes r39050 ("fix an error that calculate may be called too early before
a new simulation movement is indexed.").

Removed:
    erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/SimulationMovement_calculateCausalityState.xml
Modified:
    erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_calculate.xml
    erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_updateSimulation.xml
    erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_afterEdit.xml
    erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_solveDivergence.xml
    erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/interactions/calculate_causality.xml
    erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/scripts/SimulationMovement_calculateCausalityState.xml
    erp5/trunk/bt5/erp5_base/bt/revision
    erp5/trunk/products/ERP5/Document/SimulationMovement.py

Modified: erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_calculate.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_calculate.xml?rev=42258&r1=42257&r2=42258&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_calculate.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_calculate.xml [utf8] Wed Jan 12 12:39:31 2011
@@ -50,18 +50,9 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string># Note that delivery may have no causality state.\n
-# For instance, Accounting Transaction Lines\n
-# can be contained in a Accounting Rule Cell\n
-# of a Invoice Transaction Rule, and none of\n
-# these provide a causality workflow, but\n
-# Accounting Transaction Line is also a\n
-# possible child of a Accounting Transaction\n
-# in the Accounting Transaction Module\n
-\n
-portal = context.getPortalObject()\n
+            <value> <string>portal = context.getPortalObject()\n
 if portal.portal_workflow.isTransitionPossible(context, \'calculate\'):\n
-  context.calculate()\n
+  context.calculate(**kw)\n
 else:\n
   # Make sure no other node is moving the delivery\n
   # to \'diverged\' or \'solved\' state.\n
@@ -70,7 +61,7 @@ else:\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string></string> </value>
+            <value> <string>**kw</string> </value>
         </item>
         <item>
             <key> <string>id</string> </key>

Modified: erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_updateSimulation.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_updateSimulation.xml?rev=42258&r1=42257&r2=42258&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_updateSimulation.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_updateSimulation.xml [utf8] Wed Jan 12 12:39:31 2011
@@ -52,7 +52,6 @@
             <key> <string>_body</string> </key>
             <value> <string>delivery = context\n
 delivery_path = delivery.getPath()\n
-path_and_method_id = (delivery_path, (\'immediateReindexObject\',\'recursiveImmediateReindexObject\'))\n
 expand_tag = delivery_path + \'_expand\'\n
 tag = delivery_path + \'_updateAppliedRule\'\n
 \n
@@ -71,11 +70,10 @@ activate_kw = { \n
 # Serialization is required for avoiding parallel executions of updateAppliedRule\n
 # which may generate multiple Root Applied Rules.\n
 delivery.activate(\n
-    after_path_and_method_id=path_and_method_id,\n
     after_tag=expand_tag,\n
     tag=tag,\n
     priority=priority,\n
-    serialization_tag=delivery_path,\n
+    serialization_tag=tag,\n
     ).Delivery_updateAppliedRule(activate_kw=activate_kw)\n
 </string> </value>
         </item>

Removed: erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/SimulationMovement_calculateCausalityState.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/SimulationMovement_calculateCausalityState.xml?rev=42257&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/SimulationMovement_calculateCausalityState.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/SimulationMovement_calculateCausalityState.xml (removed)
@@ -1,71 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>Script_magic</string> </key>
-            <value> <int>3</int> </value>
-        </item>
-        <item>
-            <key> <string>_bind_names</string> </key>
-            <value>
-              <object>
-                <klass>
-                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
-                </klass>
-                <tuple/>
-                <state>
-                  <dictionary>
-                    <item>
-                        <key> <string>_asgns</string> </key>
-                        <value>
-                          <dictionary>
-                            <item>
-                                <key> <string>name_container</string> </key>
-                                <value> <string>container</string> </value>
-                            </item>
-                            <item>
-                                <key> <string>name_context</string> </key>
-                                <value> <string>context</string> </value>
-                            </item>
-                            <item>
-                                <key> <string>name_m_self</string> </key>
-                                <value> <string>script</string> </value>
-                            </item>
-                            <item>
-                                <key> <string>name_subpath</string> </key>
-                                <value> <string>traverse_subpath</string> </value>
-                            </item>
-                          </dictionary>
-                        </value>
-                    </item>
-                  </dictionary>
-                </state>
-              </object>
-            </value>
-        </item>
-        <item>
-            <key> <string>_body</string> </key>
-            <value> <string>delivery_movement = context.getDeliveryValue()\n
-\n
-if delivery_movement is not None:\n
-  delivery = delivery_movement.getRootDeliveryValue()\n
-  delivery.activate().Delivery_calculate()\n
-</string> </value>
-        </item>
-        <item>
-            <key> <string>_params</string> </key>
-            <value> <string></string> </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>SimulationMovement_calculateCausalityState</string> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>

Modified: erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_afterEdit.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_afterEdit.xml?rev=42258&r1=42257&r2=42258&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_afterEdit.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_afterEdit.xml [utf8] Wed Jan 12 12:39:31 2011
@@ -52,7 +52,8 @@
             <key> <string>_body</string> </key>
             <value> <string>delivery = state_change[\'object\']\n
 activate_kw = state_change[\'kwargs\'].get(\'activate_kw\') or {}\n
-delivery.activate(**activate_kw).updateCausalityState()\n
+tag = delivery.getPath() + \'_calculate\'\n
+delivery.activate(after_tag=tag, **activate_kw).updateCausalityState()\n
 </string> </value>
         </item>
         <item>

Modified: erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_solveDivergence.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_solveDivergence.xml?rev=42258&r1=42257&r2=42258&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_solveDivergence.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_causality_workflow/scripts/Delivery_solveDivergence.xml [utf8] Wed Jan 12 12:39:31 2011
@@ -68,7 +68,9 @@ if len(delivery_solve_property_dict) or 
     delivery_builder.solveDivergence(delivery_relative_url,\n
                                      divergence_to_accept_list=divergence_to_accept_list,\n
                                      divergence_to_adopt_list=divergence_to_adopt_list)\n
-delivery.activate().updateCausalityState()\n
+# There could be a pending \'Delivery_calculate\' activity if we solved from\n
+# \'calculating\' state, so wait that it is gone before updating causality state.\n
+delivery.activate(after_tag=delivery.getPath() + \'_calculate\').updateCausalityState()\n
 </string> </value>
         </item>
         <item>

Modified: erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/interactions/calculate_causality.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/interactions/calculate_causality.xml?rev=42258&r1=42257&r2=42258&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/interactions/calculate_causality.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/interactions/calculate_causality.xml [utf8] Wed Jan 12 12:39:31 2011
@@ -27,15 +27,15 @@
         <item>
             <key> <string>after_script_name</string> </key>
             <value>
-              <list>
-                <string>SimulationMovement_calculateCausalityState</string>
-              </list>
+              <tuple/>
             </value>
         </item>
         <item>
             <key> <string>before_commit_script_name</string> </key>
             <value>
-              <tuple/>
+              <list>
+                <string>SimulationMovement_calculateCausalityState</string>
+              </list>
             </value>
         </item>
         <item>

Modified: erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/scripts/SimulationMovement_calculateCausalityState.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/scripts/SimulationMovement_calculateCausalityState.xml?rev=42258&r1=42257&r2=42258&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/scripts/SimulationMovement_calculateCausalityState.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/simulation_movement_causality_interaction_workflow/scripts/SimulationMovement_calculateCausalityState.xml [utf8] Wed Jan 12 12:39:31 2011
@@ -50,15 +50,7 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>simulation_movement = state_change[\'object\']\n
-\n
-# It is not quite useful to invoke the method calculate when a newly created\n
-# simulation movement is not indexed yet, so it is better to wait for the indexing\n
-# to be done.\n
-path = simulation_movement.getPath()\n
-method_id_list = (\'immediateReindexObject\', \'recursiveImmediateReindexObject\')\n
-simulation_movement.activate(after_path_and_method_id=(path, method_id_list)) \\\n
-    .SimulationMovement_calculateCausalityState()\n
+            <value> <string>state_change[\'object\'].calculate()\n
 </string> </value>
         </item>
         <item>

Modified: erp5/trunk/bt5/erp5_base/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/bt/revision?rev=42258&r1=42257&r2=42258&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/bt/revision [utf8] Wed Jan 12 12:39:31 2011
@@ -1 +1 @@
-934
\ No newline at end of file
+935
\ No newline at end of file

Modified: erp5/trunk/products/ERP5/Document/SimulationMovement.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/SimulationMovement.py?rev=42258&r1=42257&r2=42258&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/SimulationMovement.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/SimulationMovement.py [utf8] Wed Jan 12 12:39:31 2011
@@ -27,6 +27,7 @@
 #
 ##############################################################################
 
+import transaction
 import zope.interface
 from AccessControl import ClassSecurityInfo
 from Products.CMFCore.utils import getToolByName
@@ -241,6 +242,35 @@ class SimulationMovement(PropertyRecorda
   #######################################################
   # Causality Workflow Methods
 
+  security.declareProtected(Permissions.ModifyPortalContent, 'calculate')
+  def calculate(self):
+    """Move related delivery in 'calculating' state by activity
+
+    Activity to update causality state is delayed until all related simulation
+    movement are reindexed.
+    This method should be only called by
+    simulation_movement_causality_interaction_workflow.
+    """
+    delivery = self.getDeliveryValue()
+    if delivery is not None:
+      delivery = delivery.getRootDeliveryValue()
+      tv = getTransactionalVariable()
+      path = self.getPath()
+      delivery_path = delivery.getPath()
+      key = 'SimulationMovement.calculate', delivery_path
+      try:
+        tv[key].append(path)
+      except KeyError:
+        tv[key] = [path]
+        def before_commit():
+          method_id_list = ('immediateReindexObject',
+                            'recursiveImmediateReindexObject')
+          tag = delivery_path + '_calculate'
+          delivery.activate(tag=tag).Delivery_calculate(activate_kw=
+            {'after_path_and_method_id': (tv[key], method_id_list)})
+          tv[key] = None # disallow further calls to 'calculate'
+        transaction.get().addBeforeCommitHook(before_commit)
+
   security.declareProtected(Permissions.ModifyPortalContent, 'expand')
   def expand(self, force=0, **kw):
     """



More information about the Erp5-report mailing list