[Erp5-report] r11369 - in /erp5/trunk/products/CMFActivity: ./ Activity/

nobody at svn.erp5.org nobody at svn.erp5.org
Sun Nov 19 11:03:06 CET 2006


Author: seb
Date: Sun Nov 19 11:02:59 2006
New Revision: 11369

URL: http://svn.erp5.org?rev=11369&view=rev
Log:
added method countMessage

Modified:
    erp5/trunk/products/CMFActivity/Activity/Queue.py
    erp5/trunk/products/CMFActivity/Activity/SQLDict.py
    erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
    erp5/trunk/products/CMFActivity/ActivityTool.py

Modified: erp5/trunk/products/CMFActivity/Activity/Queue.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/Queue.py?rev=11369&r1=11368&r2=11369&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/Queue.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/Queue.py Sun Nov 19 11:02:59 2006
@@ -158,6 +158,7 @@
           'Validation of Object %s raised exception' % '/'.join(message.object_path),
           error=sys.exc_info())
       # Do not try to call methods on objects which cause errors
+      import pdb;pdb.set_trace()
       return EXCEPTION
     return VALID
 
@@ -189,6 +190,12 @@
   def getMessageList(self, activity_tool, processing_node=None,**kw):
     return []  
 
+  def countMessage(self, activity_tool,**kw):
+    return 0
+
+  def countMessageWithTag(self, activity_tool,value):
+    return 0
+  
   # Transaction Management
   def prepareQueueMessage(self, activity_tool, m):
     # Called to prepare transaction commit for queued messages

Modified: erp5/trunk/products/CMFActivity/Activity/SQLDict.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLDict.py?rev=11369&r1=11368&r2=11369&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLDict.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLDict.py Sun Nov 19 11:02:59 2006
@@ -564,14 +564,30 @@
       return INVALID_ORDER
     return VALID
 
+  def countMessage(self, activity_tool, tag=None,path=None,
+                   method_id=None,message_uid=None,**kw):
+    """
+      Return the number of message which match the given parameter.
+    """
+    if isinstance(tag, StringType):
+      tag = [tag]
+    if isinstance(path, StringType):
+      path = [path]
+    if isinstance(message_uid, (int,long)):
+      message_uid = [message_uid]
+    if isinstance(method_id, StringType):
+      method_id = [method_id]
+    result = activity_tool.SQLDict_validateMessageList(method_id=method_id, 
+                                                       path=path,
+                                                       message_uid=message_uid, 
+                                                       tag=tag)
+    return result[0].uid_count
+
   def countMessageWithTag(self, activity_tool, value):
     """
       Return the number of message which match the given tag.
     """
-    if isinstance(value, StringType):
-      value = [value]
-    result = activity_tool.SQLDict_validateMessageList(method_id=None, message_uid=None, tag=value)
-    return result[0].uid_count
+    return self.countMessage(activity_tool,tag=value)
 
   def _validate_after_tag_and_method_id(self, activity_tool, message, value):
     # Count number of occurances of tag and method_id

Modified: erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLQueue.py?rev=11369&r1=11368&r2=11369&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLQueue.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLQueue.py Sun Nov 19 11:02:59 2006
@@ -33,6 +33,7 @@
 from Queue import VALID, INVALID_ORDER, INVALID_PATH, EXCEPTION, MAX_PROCESSING_TIME, VALIDATION_ERROR_DELAY
 from Products.CMFActivity.ActiveObject import DISTRIBUTABLE_STATE, INVOKE_ERROR_STATE, VALIDATE_ERROR_STATE
 from ZODB.POSException import ConflictError
+from types import StringType
 
 try:
   from transaction import get as get_transaction
@@ -237,6 +238,32 @@
         message_list.append(m)
     return message_list
 
+  def countMessage(self, activity_tool, tag=None,path=None,
+                   method_id=None,message_uid=None,**kw):
+    """
+      Return the number of message which match the given parameter.
+    """
+    if isinstance(tag, StringType):
+      tag = [tag]
+    if isinstance(path, StringType):
+      path = [path]
+    if isinstance(message_uid, (int,long)):
+      message_uid = [message_uid]
+    if isinstance(method_id, StringType):
+      method_id = [method_id]
+    result = activity_tool.SQLQueue_validateMessageList(method_id=method_id, 
+                                                       path=path,
+                                                       message_uid=message_uid, 
+                                                       tag=tag)
+    return result[0].uid_count
+
+  def countMessageWithTag(self, activity_tool, value):
+    """
+      Return the number of message which match the given tag.
+    """
+    return self.countMessage(activity_tool,tag=value)
+
+
   def dumpMessageList(self, activity_tool):
     # Dump all messages in the table.
     message_list = []

Modified: erp5/trunk/products/CMFActivity/ActivityTool.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/ActivityTool.py?rev=11369&r1=11368&r2=11369&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/ActivityTool.py (original)
+++ erp5/trunk/products/CMFActivity/ActivityTool.py Sun Nov 19 11:02:59 2006
@@ -883,10 +883,24 @@
       """
       message_count = 0
       for activity in activity_list:
-        try:
-          message_count += activity.countMessageWithTag(self, value)
-        except AttributeError:
-          LOG('getMessageList, could not get count message from Activity:', 0, activity)
+        message_count += activity.countMessageWithTag(self, value)
+      return message_count
+
+    security.declarePublic('countMessage')
+    def countMessage(self, **kw):
+      """
+        Return the number of messages which match the given parameter.
+
+        Parameters allowed:
+
+        method_id : the id of the method
+        path : for activities on an particular object
+        tag : activities with a particular tag
+        message_uid : activities with a particular uid
+      """
+      message_count = 0
+      for activity in activity_list:
+        message_count += activity.countMessage(self, **kw)
       return message_count
 
     security.declareProtected( CMFCorePermissions.ManagePortal , 'newActiveProcess' )




More information about the Erp5-report mailing list