Commit 1ceaaba6 authored by Vincent Pelletier's avatar Vincent Pelletier

Make all ZSQLMethod parameters mandatory.

Make all dtml tests use expr="...", so that tested values don't use acquisition. (Nice catch, Nicolas !)
Update callers to cope with those new limitations.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25266 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent db1b2f49
...@@ -91,6 +91,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -91,6 +91,7 @@ class SQLDict(RAMDict, SQLBase):
group_method_id_list = group_method_id_list, group_method_id_list = group_method_id_list,
tag_list = tag_list, tag_list = tag_list,
serialization_tag_list = serialization_tag_list, serialization_tag_list = serialization_tag_list,
processing_node_list=None,
order_validation_text_list = order_validation_text_list) order_validation_text_list = order_validation_text_list)
def prepareDeleteMessage(self, activity_tool, m): def prepareDeleteMessage(self, activity_tool, m):
...@@ -98,8 +99,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -98,8 +99,7 @@ class SQLDict(RAMDict, SQLBase):
path = '/'.join(m.object_path) path = '/'.join(m.object_path)
order_validation_text = self.getOrderValidationText(m) order_validation_text = self.getOrderValidationText(m)
uid_list = activity_tool.SQLDict_readUidList(path = path, method_id = m.method_id, uid_list = activity_tool.SQLDict_readUidList(path = path, method_id = m.method_id,
order_validation_text = order_validation_text, order_validation_text = order_validation_text)
processing_node = None)
uid_list = [x.uid for x in uid_list] uid_list = [x.uid for x in uid_list]
if len(uid_list)>0: if len(uid_list)>0:
activity_tool.SQLDict_delMessage(uid = uid_list) activity_tool.SQLDict_delMessage(uid = uid_list)
...@@ -149,7 +149,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -149,7 +149,7 @@ class SQLDict(RAMDict, SQLBase):
return 0 return 0
return 1 return 1
def getReservedMessageList(self, activity_tool, date, processing_node, limit=None, **kw): def getReservedMessageList(self, activity_tool, date, processing_node, limit=None, group_method_id=None):
""" """
Get and reserve a list of messages. Get and reserve a list of messages.
limit limit
...@@ -163,7 +163,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -163,7 +163,7 @@ class SQLDict(RAMDict, SQLBase):
""" """
result = activity_tool.SQLDict_selectReservedMessageList(processing_node=processing_node, count=limit) result = activity_tool.SQLDict_selectReservedMessageList(processing_node=processing_node, count=limit)
if len(result) == 0: if len(result) == 0:
activity_tool.SQLDict_reserveMessageList(count=limit, processing_node=processing_node, to_date=date, **kw) activity_tool.SQLDict_reserveMessageList(count=limit, processing_node=processing_node, to_date=date, group_method_id=group_method_id)
result = activity_tool.SQLDict_selectReservedMessageList(processing_node=processing_node, count=limit) result = activity_tool.SQLDict_selectReservedMessageList(processing_node=processing_node, count=limit)
return result return result
...@@ -237,11 +237,12 @@ class SQLDict(RAMDict, SQLBase): ...@@ -237,11 +237,12 @@ class SQLDict(RAMDict, SQLBase):
- group_method_id - group_method_id
- uid_to_duplicate_uid_list_dict - uid_to_duplicate_uid_list_dict
""" """
def getReservedMessageList(**kw): def getReservedMessageList(limit, group_method_id=None):
line_list = self.getReservedMessageList(activity_tool=activity_tool, line_list = self.getReservedMessageList(activity_tool=activity_tool,
date=now_date, date=now_date,
processing_node=processing_node, processing_node=processing_node,
**kw) limit=limit,
group_method_id=group_method_id)
if len(line_list): if len(line_list):
LOG('SQLDict', TRACE, 'Reserved messages: %r' % ([x.uid for x in line_list])) LOG('SQLDict', TRACE, 'Reserved messages: %r' % ([x.uid for x in line_list]))
return line_list return line_list
...@@ -366,6 +367,8 @@ class SQLDict(RAMDict, SQLBase): ...@@ -366,6 +367,8 @@ class SQLDict(RAMDict, SQLBase):
# Immediately update, because values different for every message # Immediately update, because values different for every message
activity_tool.SQLDict_setPriority( activity_tool.SQLDict_setPriority(
uid=[uid], uid=[uid],
delay=None,
rety=None,
priority=priority + 1) priority=priority + 1)
except: except:
LOG('SQLDict', WARNING, 'Failed to increase priority of %r' % (uid, ), error=sys.exc_info()) LOG('SQLDict', WARNING, 'Failed to increase priority of %r' % (uid, ), error=sys.exc_info())
...@@ -385,7 +388,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -385,7 +388,7 @@ class SQLDict(RAMDict, SQLBase):
if len(delay_uid_list): if len(delay_uid_list):
try: try:
# If this is a conflict error, do not lower the priority but only delay. # If this is a conflict error, do not lower the priority but only delay.
activity_tool.SQLDict_setPriority(uid=delay_uid_list, delay=VALIDATION_ERROR_DELAY) activity_tool.SQLDict_setPriority(uid=delay_uid_list, delay=VALIDATION_ERROR_DELAY, priority=None, retry=None)
except: except:
LOG('SQLDict', ERROR, 'Failed to delay %r' % (delay_uid_list, ), error=sys.exc_info()) LOG('SQLDict', ERROR, 'Failed to delay %r' % (delay_uid_list, ), error=sys.exc_info())
make_available_uid_list += delay_uid_list make_available_uid_list += delay_uid_list
...@@ -506,12 +509,12 @@ class SQLDict(RAMDict, SQLBase): ...@@ -506,12 +509,12 @@ class SQLDict(RAMDict, SQLBase):
get_transaction().commit() get_transaction().commit()
return not len(message_uid_priority_list) return not len(message_uid_priority_list)
def hasActivity(self, activity_tool, object, **kw): def hasActivity(self, activity_tool, object, method_id=None, only_valid=None):
hasMessage = getattr(activity_tool, 'SQLDict_hasMessage', None) hasMessage = getattr(activity_tool, 'SQLDict_hasMessage', None)
if hasMessage is not None: if hasMessage is not None:
if object is not None: if object is not None:
my_object_path = '/'.join(object.getPhysicalPath()) my_object_path = '/'.join(object.getPhysicalPath())
result = hasMessage(path=my_object_path, **kw) result = hasMessage(path=my_object_path, method_id=method_id, only_valid=only_valid)
if len(result) > 0: if len(result) > 0:
return result[0].message_count > 0 return result[0].message_count > 0
else: else:
...@@ -560,7 +563,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -560,7 +563,7 @@ class SQLDict(RAMDict, SQLBase):
activity_tool.unregisterMessage(self, m) activity_tool.unregisterMessage(self, m)
# Parse each message in SQL dict # Parse each message in SQL dict
result = readMessageList(path=path, method_id=method_id, result = readMessageList(path=path, method_id=method_id,
processing_node=None,include_processing=0) processing_node=None,include_processing=0, to_date=None)
for line in result: for line in result:
path = line.path path = line.path
line_method_id = line.method_id line_method_id = line.method_id
...@@ -593,7 +596,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -593,7 +596,7 @@ class SQLDict(RAMDict, SQLBase):
if len(result): if len(result):
uid_list = activity_tool.SQLDict_readUidList(path = path, method_id = method_id, uid_list = activity_tool.SQLDict_readUidList(path = path, method_id = method_id,
processing_node = None,) order_validation_text=None)
if len(uid_list)>0: if len(uid_list)>0:
activity_tool.SQLDict_delMessage(uid = [x.uid for x in uid_list]) activity_tool.SQLDict_delMessage(uid = [x.uid for x in uid_list])
...@@ -669,6 +672,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -669,6 +672,7 @@ class SQLDict(RAMDict, SQLBase):
message_uid=message_uid, message_uid=message_uid,
path=path, path=path,
tag=tag, tag=tag,
count=False,
serialization_tag=serialization_tag) serialization_tag=serialization_tag)
message_list = [] message_list = []
for line in result: for line in result:
...@@ -726,6 +730,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -726,6 +730,7 @@ class SQLDict(RAMDict, SQLBase):
path=path, path=path,
message_uid=message_uid, message_uid=message_uid,
tag=tag, tag=tag,
serialization_tag=None,
count=1) count=1)
return result[0].uid_count return result[0].uid_count
......
...@@ -83,6 +83,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -83,6 +83,7 @@ class SQLQueue(RAMQueue, SQLBase):
message_list=message_list, message_list=message_list,
date_list=date_list, date_list=date_list,
tag_list=tag_list, tag_list=tag_list,
processing_node_list=None,
serialization_tag_list=serialization_tag_list) serialization_tag_list=serialization_tag_list)
def prepareDeleteMessage(self, activity_tool, m): def prepareDeleteMessage(self, activity_tool, m):
...@@ -241,7 +242,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -241,7 +242,7 @@ class SQLQueue(RAMQueue, SQLBase):
if len(delay_uid_list): if len(delay_uid_list):
try: try:
# If this is a conflict error, do not lower the priority but only delay. # If this is a conflict error, do not lower the priority but only delay.
activity_tool.SQLQueue_setPriority(uid=delay_uid_list, delay=VALIDATION_ERROR_DELAY) activity_tool.SQLQueue_setPriority(uid=delay_uid_list, delay=VALIDATION_ERROR_DELAY, priority=None)
except: except:
LOG('SQLQueue', ERROR, 'Failed to delay %r' % (delay_uid_list, ), error=sys.exc_info()) LOG('SQLQueue', ERROR, 'Failed to delay %r' % (delay_uid_list, ), error=sys.exc_info())
try: try:
...@@ -345,12 +346,12 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -345,12 +346,12 @@ class SQLQueue(RAMQueue, SQLBase):
return not len(message_uid_priority_list) return not len(message_uid_priority_list)
def hasActivity(self, activity_tool, object, **kw): def hasActivity(self, activity_tool, object, method_id=None, only_valid=None):
hasMessage = getattr(activity_tool, 'SQLQueue_hasMessage', None) hasMessage = getattr(activity_tool, 'SQLQueue_hasMessage', None)
if hasMessage is not None: if hasMessage is not None:
if object is not None: if object is not None:
my_object_path = '/'.join(object.getPhysicalPath()) my_object_path = '/'.join(object.getPhysicalPath())
result = hasMessage(path=my_object_path, **kw) result = hasMessage(path=my_object_path, method_id=method_id, only_valid=only_valid)
if len(result) > 0: if len(result) > 0:
return result[0].message_count > 0 return result[0].message_count > 0
else: else:
...@@ -394,7 +395,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -394,7 +395,7 @@ class SQLQueue(RAMQueue, SQLBase):
'Could not validate %s on %s' % (m.method_id , path)) 'Could not validate %s on %s' % (m.method_id , path))
activity_tool.unregisterMessage(self, m) activity_tool.unregisterMessage(self, m)
# Parse each message in SQL queue # Parse each message in SQL queue
result = readMessageList(path=path, method_id=method_id, processing_node=None) result = readMessageList(path=path, method_id=method_id, processing_node=None, to_date=None, include_processing=0)
for line in result: for line in result:
path = line.path path = line.path
method_id = line.method_id method_id = line.method_id
...@@ -426,7 +427,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -426,7 +427,7 @@ class SQLQueue(RAMQueue, SQLBase):
message_list = [] message_list = []
readMessageList = getattr(activity_tool, 'SQLQueue_readMessageList', None) readMessageList = getattr(activity_tool, 'SQLQueue_readMessageList', None)
if readMessageList is not None: if readMessageList is not None:
result = readMessageList(path=None, method_id=None, processing_node=None) result = readMessageList(path=None, method_id=None, processing_node=None, to_date=None, include_processing=0)
for line in result: for line in result:
m = self.loadMessage(line.message) m = self.loadMessage(line.message)
m.processing_node = line.processing_node m.processing_node = line.processing_node
...@@ -448,6 +449,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -448,6 +449,7 @@ class SQLQueue(RAMQueue, SQLBase):
path=path, path=path,
message_uid=message_uid, message_uid=message_uid,
tag=tag, tag=tag,
serialization_tag=None,
count=1) count=1)
return result[0].uid_count return result[0].uid_count
...@@ -515,6 +517,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -515,6 +517,7 @@ class SQLQueue(RAMQueue, SQLBase):
message_uid=message_uid, message_uid=message_uid,
path=path, path=path,
tag=tag, tag=tag,
count=False,
serialization_tag=serialization_tag) serialization_tag=serialization_tag)
message_list = [] message_list = []
for line in result: for line in result:
......
...@@ -13,8 +13,7 @@ only_valid</params> ...@@ -13,8 +13,7 @@ only_valid</params>
SELECT count(path) as message_count FROM SELECT count(path) as message_count FROM
message message
WHERE WHERE
1 = 1 path = <dtml-sqlvar path type="string">
<dtml-if path> AND path = <dtml-sqlvar path type="string"></dtml-if> <dtml-if expr="method_id is not None">AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if> <dtml-if expr="only_valid">AND processing_node > -2</dtml-if>
<dtml-if only_valid>AND processing_node > -2</dtml-if>
...@@ -21,9 +21,9 @@ WHERE ...@@ -21,9 +21,9 @@ WHERE
1 = 1 1 = 1
<dtml-if expr="not(include_processing)"> AND processing = 0 </dtml-if> <dtml-if expr="not(include_processing)"> AND processing = 0 </dtml-if>
<dtml-if expr="processing_node is not None"> AND processing_node = <dtml-sqlvar processing_node type="int"> </dtml-if> <dtml-if expr="processing_node is not None"> AND processing_node = <dtml-sqlvar processing_node type="int"> </dtml-if>
<dtml-if path>AND path = <dtml-sqlvar path type="string"> </dtml-if> <dtml-if expr="path is not None"> AND path = <dtml-sqlvar path type="string"> </dtml-if>
<dtml-if method_id> AND method_id = <dtml-sqlvar method_id type="string"> </dtml-if> <dtml-if expr="method_id is not None"> AND method_id = <dtml-sqlvar method_id type="string"> </dtml-if>
<dtml-if to_date> AND date <= <dtml-sqlvar to_date type="datetime"> </dtml-if> <dtml-if expr="to_date is not None"> AND date <= <dtml-sqlvar to_date type="datetime"> </dtml-if>
ORDER BY ORDER BY
priority, date, uid priority, date, uid
LIMIT <dtml-sqlvar offset type="int">, <dtml-sqlvar count type="int"> LIMIT <dtml-sqlvar offset type="int">, <dtml-sqlvar count type="int">
...@@ -16,6 +16,6 @@ SELECT uid FROM ...@@ -16,6 +16,6 @@ SELECT uid FROM
message message
WHERE WHERE
processing = 0 processing = 0
<dtml-if method_id> AND method_id = <dtml-sqlvar method_id type="string"> </dtml-if> <dtml-if expr="method_id is not None"> AND method_id = <dtml-sqlvar method_id type="string"> </dtml-if>
<dtml-if path> AND path = <dtml-sqlvar path type="string"> </dtml-if> <dtml-if expr="path is not None"> AND path = <dtml-sqlvar path type="string"> </dtml-if>
<dtml-if order_validation_text> AND order_validation_text = <dtml-sqlvar order_validation_text type="string"> </dtml-if> <dtml-if expr="order_validation_text is not None"> AND order_validation_text = <dtml-sqlvar order_validation_text type="string"> </dtml-if>
...@@ -19,11 +19,9 @@ SET ...@@ -19,11 +19,9 @@ SET
WHERE WHERE
processing_node=0 processing_node=0
AND date <= <dtml-sqlvar to_date type="datetime"> AND date <= <dtml-sqlvar to_date type="datetime">
<dtml-if group_method_id> AND group_method_id = <dtml-sqlvar group_method_id type="string"> </dtml-if> <dtml-if expr="group_method_id is not None"> AND group_method_id = <dtml-sqlvar group_method_id type="string"> </dtml-if>
ORDER BY ORDER BY
priority, date, uid priority, date, uid
<dtml-if count> LIMIT <dtml-sqlvar count type="int">
LIMIT <dtml-sqlvar count type="int">
</dtml-if>
<dtml-var sql_delimiter> <dtml-var sql_delimiter>
COMMIT COMMIT
...@@ -16,6 +16,6 @@ FROM ...@@ -16,6 +16,6 @@ FROM
WHERE WHERE
processing_node = <dtml-sqlvar processing_node type="int"> processing_node = <dtml-sqlvar processing_node type="int">
AND processing = 0 AND processing = 0
<dtml-if count> <dtml-if expr="count is not None">
LIMIT <dtml-sqlvar count type="int"> LIMIT <dtml-sqlvar count type="int">
</dtml-if> </dtml-if>
...@@ -16,13 +16,13 @@ UPDATE ...@@ -16,13 +16,13 @@ UPDATE
message message
SET SET
processing = 0 processing = 0
<dtml-if priority> <dtml-if expr="priority is not None">
, priority = <dtml-sqlvar priority type="int"> , priority = <dtml-sqlvar priority type="int">
</dtml-if> </dtml-if>
<dtml-if delay> <dtml-if expr="delay is not None">
, date = DATE_ADD(UTC_TIMESTAMP(), INTERVAL <dtml-sqlvar delay type="int"> * (retry + 1) SECOND) , date = DATE_ADD(UTC_TIMESTAMP(), INTERVAL <dtml-sqlvar delay type="int"> * (retry + 1) SECOND)
</dtml-if> </dtml-if>
<dtml-if retry> <dtml-if expr="retry is not None">
, retry = retry + <dtml-sqlvar retry type="int"> , retry = retry + <dtml-sqlvar retry type="int">
</dtml-if> </dtml-if>
WHERE WHERE
......
...@@ -15,7 +15,7 @@ UPDATE ...@@ -15,7 +15,7 @@ UPDATE
SET SET
date = DATE_SUB(date, INTERVAL <dtml-sqlvar delay type="int"> SECOND), date = DATE_SUB(date, INTERVAL <dtml-sqlvar delay type="int"> SECOND),
processing_date = DATE_SUB(processing_date, INTERVAL <dtml-sqlvar delay type="int"> SECOND) processing_date = DATE_SUB(processing_date, INTERVAL <dtml-sqlvar delay type="int"> SECOND)
<dtml-if retry> <dtml-if expr="retry is not None">
,retry = GREATEST(retry,<dtml-sqlvar retry type="int">) - <dtml-sqlvar retry type="int"> ,retry = GREATEST(retry,<dtml-sqlvar retry type="int">) - <dtml-sqlvar retry type="int">
</dtml-if> </dtml-if>
WHERE WHERE
......
...@@ -15,7 +15,7 @@ count ...@@ -15,7 +15,7 @@ count
serialization_tag serialization_tag
</params> </params>
SELECT SELECT
<dtml-if count> <dtml-if expr="count">
COUNT(*) AS uid_count COUNT(*) AS uid_count
<dtml-else> <dtml-else>
* *
...@@ -24,23 +24,23 @@ FROM ...@@ -24,23 +24,23 @@ FROM
message message
WHERE WHERE
processing_node >= -2 processing_node >= -2
<dtml-if method_id> <dtml-if expr="method_id is not None">
AND method_id IN ( AND method_id IN (
<dtml-in method_id><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in> <dtml-in method_id><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
) )
</dtml-if> </dtml-if>
<dtml-if message_uid>AND uid = <dtml-sqlvar message_uid type="int"> </dtml-if> <dtml-if expr="message_uid is not None">AND uid = <dtml-sqlvar message_uid type="int"> </dtml-if>
<dtml-if path> <dtml-if expr="path is not None">
AND path IN ( AND path IN (
<dtml-in path><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in> <dtml-in path><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
) )
</dtml-if> </dtml-if>
<dtml-if tag> <dtml-if expr="tag is not None">
AND tag IN ( AND tag IN (
<dtml-in tag><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in> <dtml-in tag><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
) )
</dtml-if> </dtml-if>
<dtml-if serialization_tag> <dtml-if expr="serialization_tag is not None">
AND processing_node > -1 AND processing_node > -1
AND serialization_tag = <dtml-sqlvar serialization_tag type="string"> AND serialization_tag = <dtml-sqlvar serialization_tag type="string">
</dtml-if> </dtml-if>
...@@ -26,9 +26,9 @@ VALUES ...@@ -26,9 +26,9 @@ VALUES
( (
<dtml-sqlvar expr="uid_list[loop_item]" type="int">, <dtml-sqlvar expr="uid_list[loop_item]" type="int">,
<dtml-sqlvar expr="path_list[loop_item]" type="string">, <dtml-sqlvar expr="path_list[loop_item]" type="string">,
<dtml-if date_list><dtml-if expr="date_list[loop_item] is not None"><dtml-sqlvar expr="date_list[loop_item]" type="datetime"><dtml-else>UTC_TIMESTAMP()</dtml-if><dtml-else>UTC_TIMESTAMP()</dtml-if>, <dtml-if expr="date_list is not None"><dtml-if expr="date_list[loop_item] is not None"><dtml-sqlvar expr="date_list[loop_item]" type="datetime"><dtml-else>UTC_TIMESTAMP()</dtml-if><dtml-else>UTC_TIMESTAMP()</dtml-if>,
<dtml-sqlvar expr="method_id_list[loop_item]" type="string">, <dtml-sqlvar expr="method_id_list[loop_item]" type="string">,
<dtml-if processing_node_list><dtml-sqlvar expr="processing_node_list[loop_item]" type="int"><dtml-else>-1</dtml-if>, <dtml-if expr="processing_node_list is not None"><dtml-sqlvar expr="processing_node_list[loop_item]" type="int"><dtml-else>-1</dtml-if>,
0, 0,
<dtml-sqlvar expr="priority_list[loop_item]" type="int">, <dtml-sqlvar expr="priority_list[loop_item]" type="int">,
<dtml-sqlvar expr="group_method_id_list[loop_item]" type="string">, <dtml-sqlvar expr="group_method_id_list[loop_item]" type="string">,
......
...@@ -13,8 +13,7 @@ only_valid</params> ...@@ -13,8 +13,7 @@ only_valid</params>
SELECT count(path) as message_count FROM SELECT count(path) as message_count FROM
message_queue message_queue
WHERE WHERE
1 = 1 path = <dtml-sqlvar path type="string">
<dtml-if path>AND path = <dtml-sqlvar path type="string"></dtml-if> <dtml-if expr="method_id is not None">AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if> <dtml-if expr="only_valid">AND processing_node > -2</dtml-if>
<dtml-if only_valid>AND processing_node > -2</dtml-if>
...@@ -21,9 +21,9 @@ WHERE ...@@ -21,9 +21,9 @@ WHERE
1 = 1 1 = 1
<dtml-if expr="not(include_processing)"> AND processing = 0 </dtml-if> <dtml-if expr="not(include_processing)"> AND processing = 0 </dtml-if>
<dtml-if expr="processing_node is not None"> AND processing_node = <dtml-sqlvar processing_node type="int"> </dtml-if> <dtml-if expr="processing_node is not None"> AND processing_node = <dtml-sqlvar processing_node type="int"> </dtml-if>
<dtml-if path>AND path = <dtml-sqlvar path type="string"></dtml-if> <dtml-if expr="path is not None">AND path = <dtml-sqlvar path type="string"></dtml-if>
<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if> <dtml-if expr="method_id is not None">AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
<dtml-if to_date> AND date <= <dtml-sqlvar to_date type="datetime"> </dtml-if> <dtml-if expr="to_date is not None"> AND date <= <dtml-sqlvar to_date type="datetime"> </dtml-if>
ORDER BY ORDER BY
priority, date, uid priority, date, uid
LIMIT <dtml-sqlvar offset type="int">, <dtml-sqlvar count type="int"> LIMIT <dtml-sqlvar offset type="int">, <dtml-sqlvar count type="int">
...@@ -20,8 +20,6 @@ WHERE ...@@ -20,8 +20,6 @@ WHERE
AND date <= <dtml-sqlvar to_date type="datetime"> AND date <= <dtml-sqlvar to_date type="datetime">
ORDER BY ORDER BY
priority, date, uid priority, date, uid
<dtml-if count> LIMIT <dtml-sqlvar count type="int">
LIMIT <dtml-sqlvar count type="int">
</dtml-if>
<dtml-var sql_delimiter> <dtml-var sql_delimiter>
COMMIT COMMIT
...@@ -16,6 +16,6 @@ FROM ...@@ -16,6 +16,6 @@ FROM
WHERE WHERE
processing_node = <dtml-sqlvar processing_node type="int"> processing_node = <dtml-sqlvar processing_node type="int">
AND processing = 0 AND processing = 0
<dtml-if count> <dtml-if expr="count is not None">
LIMIT <dtml-sqlvar count type="int"> LIMIT <dtml-sqlvar count type="int">
</dtml-if> </dtml-if>
...@@ -15,10 +15,10 @@ UPDATE ...@@ -15,10 +15,10 @@ UPDATE
message_queue message_queue
SET SET
processing = 0 processing = 0
<dtml-if priority> <dtml-if expr="priority is not None">
, priority = <dtml-sqlvar priority type="int"> , priority = <dtml-sqlvar priority type="int">
</dtml-if> </dtml-if>
<dtml-if delay> <dtml-if expr="delay is not None">
, date = DATE_ADD(UTC_TIMESTAMP(), INTERVAL <dtml-sqlvar delay type="int"> SECOND) , date = DATE_ADD(UTC_TIMESTAMP(), INTERVAL <dtml-sqlvar delay type="int"> SECOND)
</dtml-if> </dtml-if>
WHERE WHERE
......
...@@ -15,7 +15,7 @@ count ...@@ -15,7 +15,7 @@ count
serialization_tag serialization_tag
</params> </params>
SELECT SELECT
<dtml-if count> <dtml-if expr="count">
COUNT(*) AS uid_count COUNT(*) AS uid_count
<dtml-else> <dtml-else>
* *
...@@ -24,23 +24,23 @@ FROM ...@@ -24,23 +24,23 @@ FROM
message_queue message_queue
WHERE WHERE
processing_node >= -2 processing_node >= -2
<dtml-if method_id> <dtml-if expr="method_id is not None">
AND method_id IN ( AND method_id IN (
<dtml-in method_id><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in> <dtml-in method_id><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
) )
</dtml-if> </dtml-if>
<dtml-if message_uid>AND uid = <dtml-sqlvar message_uid type="int"> </dtml-if> <dtml-if expr="message_uid is not None">AND uid = <dtml-sqlvar message_uid type="int"> </dtml-if>
<dtml-if path> <dtml-if expr="path is not None">
AND path IN ( AND path IN (
<dtml-in path><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in> <dtml-in path><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
) )
</dtml-if> </dtml-if>
<dtml-if tag> <dtml-if expr="tag is not None">
AND tag IN ( AND tag IN (
<dtml-in tag><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in> <dtml-in tag><dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
) )
</dtml-if> </dtml-if>
<dtml-if serialization_tag> <dtml-if expr="serialization_tag is not None">
AND processing_node > -1 AND processing_node > -1
AND serialization_tag = <dtml-sqlvar serialization_tag type="string"> AND serialization_tag = <dtml-sqlvar serialization_tag type="string">
</dtml-if> </dtml-if>
...@@ -25,9 +25,9 @@ VALUES ...@@ -25,9 +25,9 @@ VALUES
( (
<dtml-sqlvar expr="uid_list[loop_item]" type="int">, <dtml-sqlvar expr="uid_list[loop_item]" type="int">,
<dtml-sqlvar expr="path_list[loop_item]" type="string">, <dtml-sqlvar expr="path_list[loop_item]" type="string">,
<dtml-if date_list><dtml-if expr="date_list[loop_item] is not None"><dtml-sqlvar expr="date_list[loop_item]" type="datetime"><dtml-else>UTC_TIMESTAMP()</dtml-if><dtml-else>UTC_TIMESTAMP()</dtml-if>, <dtml-if expr="date_list is not None"><dtml-if expr="date_list[loop_item] is not None"><dtml-sqlvar expr="date_list[loop_item]" type="datetime"><dtml-else>UTC_TIMESTAMP()</dtml-if><dtml-else>UTC_TIMESTAMP()</dtml-if>,
<dtml-sqlvar expr="method_id_list[loop_item]" type="string">, <dtml-sqlvar expr="method_id_list[loop_item]" type="string">,
<dtml-if processing_node_list><dtml-sqlvar expr="processing_node_list[loop_item]" type="int"><dtml-else>-1</dtml-if>, <dtml-if expr="processing_node_list is not None"><dtml-sqlvar expr="processing_node_list[loop_item]" type="int"><dtml-else>-1</dtml-if>,
0, 0,
<dtml-sqlvar expr="priority_list[loop_item]" type="int">, <dtml-sqlvar expr="priority_list[loop_item]" type="int">,
<dtml-sqlvar expr="tag_list[loop_item]" type="string">, <dtml-sqlvar expr="tag_list[loop_item]" type="string">,
......
...@@ -1955,7 +1955,8 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -1955,7 +1955,8 @@ class TestCMFActivity(ERP5TypeTestCase):
processing_node_list=[-2], processing_node_list=[-2],
group_method_id_list=[''], group_method_id_list=[''],
tag_list=[''], tag_list=[''],
order_validation_text_list=[''] order_validation_text_list=[''],
serialization_tag_list=[''],
) )
if len(object_list) == 2: if len(object_list) == 2:
# Remove one entry from object list: this is understood by caller as a # Remove one entry from object list: this is understood by caller as a
...@@ -2011,7 +2012,8 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2011,7 +2012,8 @@ class TestCMFActivity(ERP5TypeTestCase):
processing_node_list=[-2], processing_node_list=[-2],
group_method_id_list=[''], group_method_id_list=[''],
tag_list=[''], tag_list=[''],
order_validation_text_list=[''] order_validation_text_list=[''],
serialization_tag_list=['']
) )
# Fail # Fail
raise ValueError, 'This method always fail' raise ValueError, 'This method always fail'
...@@ -2077,7 +2079,8 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2077,7 +2079,8 @@ class TestCMFActivity(ERP5TypeTestCase):
processing_node_list=[-2], processing_node_list=[-2],
group_method_id_list=[''], group_method_id_list=[''],
tag_list=[''], tag_list=[''],
order_validation_text_list=[''] order_validation_text_list=[''],
serialization_tag_list=[''],
) )
# Fail # Fail
raise ValueError, 'This method always fail' raise ValueError, 'This method always fail'
...@@ -2134,7 +2137,8 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2134,7 +2137,8 @@ class TestCMFActivity(ERP5TypeTestCase):
processing_node_list=[-2], processing_node_list=[-2],
group_method_id_list=[''], group_method_id_list=[''],
tag_list=[''], tag_list=[''],
order_validation_text_list=[''] order_validation_text_list=[''],
serialization_tag_list=[''],
) )
# Fail # Fail
raise ValueError, 'This method always fail' raise ValueError, 'This method always fail'
...@@ -2300,10 +2304,14 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2300,10 +2304,14 @@ class TestCMFActivity(ERP5TypeTestCase):
obj.activate(activity=activity, priority=6).failingMethod() obj.activate(activity=activity, priority=6).failingMethod()
get_transaction().commit() get_transaction().commit()
self.flushAllActivities(silent=1, loop_size=100) self.flushAllActivities(silent=1, loop_size=100)
with_processing_len = len(readMessageList(method_id='failingMethod', with_processing_len = len(readMessageList(path=None,
to_date=None,
method_id='failingMethod',
include_processing=1, include_processing=1,
processing_node=None)) processing_node=None))
without_processing_len = len(readMessageList(method_id='failingMethod', without_processing_len = len(readMessageList(path=None,
to_date=None,
method_id='failingMethod',
include_processing=0, include_processing=0,
processing_node=None)) processing_node=None))
self.assertEqual(with_processing_len, 1) self.assertEqual(with_processing_len, 1)
...@@ -2366,7 +2374,7 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2366,7 +2374,7 @@ class TestCMFActivity(ERP5TypeTestCase):
processing_node_list=[-2], processing_node_list=[-2],
group_method_id_list=[''], group_method_id_list=[''],
tag_list=[''], tag_list=[''],
order_validation_text_list=[''] order_validation_text_list=[''],
) )
get_transaction().__class__.commit = fake_commit get_transaction().__class__.commit = fake_commit
object_list[:] = [] object_list[:] = []
...@@ -2424,7 +2432,7 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2424,7 +2432,7 @@ class TestCMFActivity(ERP5TypeTestCase):
processing_node_list=[-2], processing_node_list=[-2],
group_method_id_list=[''], group_method_id_list=[''],
tag_list=[''], tag_list=[''],
order_validation_text_list=[''] order_validation_text_list=[''],
) )
get_transaction().__class__.commit = fake_commit get_transaction().__class__.commit = fake_commit
commit = get_transaction().__class__.commit commit = get_transaction().__class__.commit
...@@ -2852,10 +2860,12 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2852,10 +2860,12 @@ class TestCMFActivity(ERP5TypeTestCase):
self.assertEqual(len(activity_tool.getMessageList()), 1) self.assertEqual(len(activity_tool.getMessageList()), 1)
activity_tool.distribute() activity_tool.distribute()
self.assertEquals(len(readMessageList(processing_node=-3, self.assertEquals(len(readMessageList(processing_node=-3,
include_processing=1)), 0) include_processing=1, path=None, method_id=None,
to_date=None)), 0)
activity_tool.tic() activity_tool.tic()
self.assertEquals(len(readMessageList(processing_node=-3, self.assertEquals(len(readMessageList(processing_node=-3,
include_processing=1)), 1) include_processing=1, path=None, method_id=None,
to_date=None)), 1)
def test_109_checkMissingActivityContextObjectSQLDict(self, quiet=0, def test_109_checkMissingActivityContextObjectSQLDict(self, quiet=0,
run=run_all_test): run=run_all_test):
...@@ -2908,10 +2918,12 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2908,10 +2918,12 @@ class TestCMFActivity(ERP5TypeTestCase):
self.assertEqual(len(activity_tool.getMessageList()), 2) self.assertEqual(len(activity_tool.getMessageList()), 2)
activity_tool.distribute() activity_tool.distribute()
self.assertEquals(len(readMessageList(processing_node=-3, self.assertEquals(len(readMessageList(processing_node=-3,
include_processing=1)), 0) include_processing=1, path=None, method_id=None,
to_date=None)), 0)
activity_tool.tic() activity_tool.tic()
self.assertEquals(len(readMessageList(processing_node=-3, self.assertEquals(len(readMessageList(processing_node=-3,
include_processing=1)), 1) include_processing=1, path=None, method_id=None,
to_date=None)), 1)
# The message excuted on "organisation_2" must have succeeded. # The message excuted on "organisation_2" must have succeeded.
self.assertEqual(len(activity_tool.getMessageList()), 1) self.assertEqual(len(activity_tool.getMessageList()), 1)
...@@ -3128,8 +3140,8 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -3128,8 +3140,8 @@ class TestCMFActivity(ERP5TypeTestCase):
# Use SQLDict with no group method so that both activities won't be # Use SQLDict with no group method so that both activities won't be
# executed in the same batch, letting activity tool a chance to check # executed in the same batch, letting activity tool a chance to check
# if execution should stop processing activities. # if execution should stop processing activities.
organisation.activate(activity='SQLDict', priority=1).waitingActivity() organisation.activate(activity='SQLDict', tag='foo').waitingActivity()
organisation.activate(activity='SQLDict', priority=2).getTitle() organisation.activate(activity='SQLDict', after_tag='foo').getTitle()
get_transaction().commit() get_transaction().commit()
self.assertEqual(len(activity_tool.getMessageList()), 2) self.assertEqual(len(activity_tool.getMessageList()), 2)
activity_tool.distribute() activity_tool.distribute()
......
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