Commit 53d10e8e authored by Vincent Pelletier's avatar Vincent Pelletier

CMFActivity: Factorise default group_method_cost value.

parent 4dd6848a
...@@ -555,7 +555,7 @@ CREATE TABLE %s ( ...@@ -555,7 +555,7 @@ CREATE TABLE %s (
group_method_id = m.line.group_method_id group_method_id = m.line.group_method_id
if group_method_id[0] != '\0': if group_method_id[0] != '\0':
# Count the number of objects to prevent too many objects. # Count the number of objects to prevent too many objects.
cost = m.activity_kw.get('group_method_cost', .01) cost = m.getGroupMethodCost()
assert 0 < cost <= 1, (self.sql_table, uid) assert 0 < cost <= 1, (self.sql_table, uid)
count = m.getObjectCount(activity_tool) count = m.getObjectCount(activity_tool)
# this is heuristic (messages with same group_method_id # this is heuristic (messages with same group_method_id
...@@ -584,7 +584,7 @@ CREATE TABLE %s ( ...@@ -584,7 +584,7 @@ CREATE TABLE %s (
continue continue
uid_to_duplicate_uid_list_dict[uid] = uid_list uid_to_duplicate_uid_list_dict[uid] = uid_list
cost += m.getObjectCount(activity_tool) * \ cost += m.getObjectCount(activity_tool) * \
m.activity_kw.get('group_method_cost', .01) m.getGroupMethodCost()
message_list.append(m) message_list.append(m)
if cost >= 1: if cost >= 1:
# Unreserve extra messages as soon as possible. # Unreserve extra messages as soon as possible.
......
...@@ -251,6 +251,10 @@ class Message(BaseMessage): ...@@ -251,6 +251,10 @@ class Message(BaseMessage):
group_method_id = 'portal_activities/dummyGroupMethod/' + self.method_id group_method_id = 'portal_activities/dummyGroupMethod/' + self.method_id
return group_method_id + '\0' + get('group_id', '') return group_method_id + '\0' + get('group_id', '')
def getGroupMethodCost(self):
# Meaningless if called on a non-grouped message
return self.activity_kw.get('group_method_cost', .01)
def _getObject(self, activity_tool): def _getObject(self, activity_tool):
obj = activity_tool.getPhysicalRoot() obj = activity_tool.getPhysicalRoot()
for id in self.object_path[1:]: for id in self.object_path[1:]:
......
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