From 3b6cfdfb9f8c365267f8a2b762b85cbd81e2b276 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Fri, 25 Jul 2008 08:21:29 +0000
Subject: [PATCH] Only validate new messages; All other states are subsequent
 to a validation (regular of by user's choice by modifying sql tables). This
 fixes impossibility to invoke by hand validated messages not being executed
 when they have a serialization_tage set.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22647 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/CMFActivity/Activity/SQLDict.py  | 7 +++++--
 product/CMFActivity/Activity/SQLQueue.py | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/product/CMFActivity/Activity/SQLDict.py b/product/CMFActivity/Activity/SQLDict.py
index 6f2258c155..e0f70d4f10 100644
--- a/product/CMFActivity/Activity/SQLDict.py
+++ b/product/CMFActivity/Activity/SQLDict.py
@@ -569,8 +569,11 @@ class SQLDict(RAMDict, SQLBase):
           method_dict[line_method_id] = 1
           m = self.loadMessage(line.message, uid = line.uid)
           if invoke:
-            # First Validate
-            validate_value = m.validate(self, activity_tool)
+            # First Validate (only if message is marked as new)
+            if line.processing_node == -1:
+              validate_value = m.validate(self, activity_tool)
+            else:
+              validate_value = VALID
 #             LOG('SQLDict.flush validate_value',0,validate_value)
             if validate_value is VALID:
               activity_tool.invoke(m) # Try to invoke the message - what happens if invoke calls flushActivity ??
diff --git a/product/CMFActivity/Activity/SQLQueue.py b/product/CMFActivity/Activity/SQLQueue.py
index d222636263..6b11370ce1 100644
--- a/product/CMFActivity/Activity/SQLQueue.py
+++ b/product/CMFActivity/Activity/SQLQueue.py
@@ -376,8 +376,11 @@ class SQLQueue(RAMQueue, SQLBase):
       for m in activity_tool.getRegisteredMessageList(self):
         if object_path == m.object_path and (method_id is None or method_id == m.method_id):
           if invoke:
-            # First Validate
-            validate_value = m.validate(self, activity_tool)
+            # First Validate (only if message is marked as new)
+            if line.processing_node == -1:
+              validate_value = m.validate(self, activity_tool)
+            else:
+              validate_value = VALID
             if validate_value is VALID:
               activity_tool.invoke(m) # Try to invoke the message - what happens if invoke calls flushActivity ??
               if m.is_executed != MESSAGE_EXECUTED:                                                 # Make sure message could be invoked
-- 
2.30.9