Commit a0d61569 authored by Vincent Pelletier's avatar Vincent Pelletier

erp5_full_text_mroonga_catalog: Inherit priority.

Spawn fulltext indexation activity with the same priority as the
top-priority activity part of current activity group.
And expose the priority of current activity (top-priority for grouped
activities).
Ideally, the priority of each spawned activity should be the top-priority
of all activities member of this activity group for corresponding document.
But there is no obvious way to achieve that through indexation API without
increasing complexity significantly.
parent c502e47c
# This script is called to defer fulltext indexing in a lower priority.
# This script is called to defer fulltext indexing.
METHOD_ID = script.id + 'Activity'
GROUP_METHOD_ID = context.getPath() + '/' + METHOD_ID
activateObject = context.getPortalObject().portal_activities.activateObject
try:
priority = context.getActivityRuntimeEnvironment().getPriority()
except KeyError:
# called outside of an activity, could be an immediate reindexation
# XXX: duplicates default priority for sake of simplicity and speed.
# Strictly, this could also look-up default activate parameters, but on
# which document ? Traversing is expensive. So keep things fast by default.
priority = 1
for document, root_document_path in zip(getPath, getRootDocumentPath):
getattr(
activateObject(
document,
activity='SQLDict',
priority=4,
priority=priority,
node='same',
group_method_id=GROUP_METHOD_ID,
serialization_tag='full_text_' + root_document_path,
......
......@@ -631,7 +631,10 @@ CREATE TABLE %s (
method = activity_tool.invokeGroup
args = (group_method_id, message_list, self.__class__.__name__,
hasattr(self, 'generateMessageUID'))
activity_runtime_environment = ActivityRuntimeEnvironment(None)
activity_runtime_environment = ActivityRuntimeEnvironment(
None,
priority=min(x.line.priority for x in message_list),
)
else:
method = activity_tool.invoke
message, = message_list
......
......@@ -41,8 +41,9 @@ class BaseMessage:
class ActivityRuntimeEnvironment(object):
security = ClassSecurityInfo()
def __init__(self, message):
def __init__(self, message, priority=None):
self._message = message
self._priority = priority
def __enter__(self):
assert not hasattr(_activity_runtime_environment, 'value')
......@@ -56,6 +57,13 @@ class ActivityRuntimeEnvironment(object):
def getTag(self, default=None):
return self._message.activity_kw.get('tag', default)
security.declarePublic('getPriority')
def getPriority(self):
result = self._priority
if result is None:
return self._message.line.priority
return result
security.declarePublic('edit')
def edit(self, **kw):
# There is no point allowing to modify other attributes from a message
......
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