Commit 43d5da67 authored by Julien Muchembled's avatar Julien Muchembled

Move _validate_* methods from SQLDict and SQLQueue to SQLBase, and fix...

Move _validate_* methods from SQLDict and SQLQueue to SQLBase, and fix checking of parameters (cf r24586).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25481 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cb9b33f5
......@@ -26,7 +26,7 @@
#
##############################################################################
from zLOG import LOG, INFO
from zLOG import LOG, INFO, WARNING
from ZODB.POSException import ConflictError
class SQLBase:
......@@ -67,3 +67,32 @@ class SQLBase:
break
return result
def _validate_after_method_id(self, activity_tool, message, value):
return self._validate(activity_tool, method_id=value)
def _validate_after_path(self, activity_tool, message, value):
return self._validate(activity_tool, path=value)
def _validate_after_message_uid(self, activity_tool, message, value):
return self._validate(activity_tool, message_uid=value)
def _validate_after_path_and_method_id(self, activity_tool, message, value):
if not (isinstance(value, (tuple, list)) and len(value) == 2):
LOG('CMFActivity', WARNING,
'unable to recognize value for after_path_and_method_id: %r' % (value,))
return []
return self._validate(activity_tool, path=value[0], method_id=value[1])
def _validate_after_tag(self, activity_tool, message, value):
return self._validate(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
if not (isinstance(value, (tuple, list)) and len(value) == 2):
LOG('CMFActivity', WARNING,
'unable to recognize value for after_tag_and_method_id: %r' % (value,))
return []
return self._validate(activity_tool, tag=value[0], method_id=value[1])
def _validate_serialization_tag(self, activity_tool, message, value):
return self._validate(activity_tool, serialization_tag=value)
......@@ -685,36 +685,6 @@ class SQLDict(RAMDict, SQLBase):
else:
return []
def _validate_after_method_id(self, activity_tool, message, value):
return self._validate(activity_tool, method_id=value)
def _validate_after_path(self, activity_tool, message, value):
return self._validate(activity_tool, path=value)
def _validate_after_message_uid(self, activity_tool, message, value):
return self._validate(activity_tool, message_uid=value)
def _validate_after_path_and_method_id(self, activity_tool, message, value):
if not (isinstance(value, (tuple, list)) or len(value) == 2):
LOG('CMFActivity', WARNING,
'unable to recognize value for after_path_and_method_id: %r' % (value,))
return []
return self._validate(activity_tool, path=value[0], method_id=value[1])
def _validate_after_tag(self, activity_tool, message, value):
return self._validate(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
if not isinstance(value, (tuple, list)) or len(value) < 2:
LOG('CMFActivity', WARNING,
'unable to recognize value for after_tag_and_method_id: %r' % (value,))
return []
return self._validate(activity_tool, tag=value[0], method_id=value[1])
def _validate_serialization_tag(self, activity_tool, message, value):
return self._validate(activity_tool, serialization_tag=value)
def countMessage(self, activity_tool, tag=None, path=None,
method_id=None, message_uid=None, **kw):
"""Return the number of messages which match the given parameters.
......
......@@ -530,35 +530,6 @@ class SQLQueue(RAMQueue, SQLBase):
else:
return []
def _validate_after_method_id(self, activity_tool, message, value):
return self._validate(activity_tool, method_id=value)
def _validate_after_path(self, activity_tool, message, value):
return self._validate(activity_tool, path=value)
def _validate_after_message_uid(self, activity_tool, message, value):
return self._validate(activity_tool, message_uid=value)
def _validate_after_path_and_method_id(self, activity_tool, message, value):
if not (isinstance(value, (tuple, list)) and len(value) == 2):
LOG('CMFActivity', WARNING,
'unable to recognize value for after_path_and_method_id: %r' % (value,))
return []
return self._validate(activity_tool, path=value[0], method_id=value[1])
def _validate_after_tag(self, activity_tool, message, value):
return self._validate(activity_tool, tag=value)
def _validate_after_tag_and_method_id(self, activity_tool, message, value):
if not isinstance(value, (tuple, list)) or len(value) < 2:
LOG('CMFActivity', WARNING,
'unable to recognize value for after_tag_and_method_id: %r' % (value,))
return []
return self._validate(activity_tool, tag=value[0], method_id=value[1])
def _validate_serialization_tag(self, activity_tool, message, value):
return self._validate(activity_tool, serialization_tag=value)
# Required for tests (time shift)
def timeShift(self, activity_tool, delay, processing_node = None):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment