Commit eff019bc authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fixup! erp5_full_text_mroonga_catalog: defer fulltext index and unindex using...

fixup! erp5_full_text_mroonga_catalog: defer fulltext index and unindex using dedicated catalog keys.
parent 1c4f6aa0
# This script is called to defer fulltext indexing.
METHOD_ID = script.id + 'Activity'
GROUP_METHOD_ID = context.getRelativeUrl() + '/' + METHOD_ID
GROUP_METHOD_ID = 'portal_catalog/catalogObjectList'
activateObject = context.getPortalObject().portal_activities.activateObject
try:
priority = context.getActivityRuntimeEnvironment().getPriority()
......@@ -26,4 +26,4 @@ for document in getPath:
serialization_tag='full_text_' + document,
),
METHOD_ID,
)()
)(check_uid=0, deferred=1)
from Products.ERP5Type.Utils import UpperCase
from ZODB.POSException import ConflictError
from zExceptions import Unauthorized
import six
for method_id in context.getSqlDeferredCatalogObjectListList():
method = getattr(context, method_id)
property_list = method.arguments_src.split()
parameter_dict = {x: [] for x in property_list}
for group_object in object_list:
tmp_dict = {}
try:
obj = group_object.object
for property in property_list:
getter = getattr(obj, property, None)
if callable(getter):
value = getter()
else:
value = getattr(obj, 'get%s' % UpperCase(property))()
tmp_dict[property] = value
except ConflictError:
raise
except Unauthorized: # should happen in tricky testERP5Catalog tests only
# Fake activity success: if indexation cannot View document, ignore it.
group_object.result = None
except Exception:
group_object.raised()
else:
for property, value in six.iteritems(tmp_dict):
parameter_dict[property].append(value)
group_object.result = None
if parameter_dict:
method(**parameter_dict)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Python Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>object_list</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SQLCatalog_deferFullTextIndexActivity</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Python Script</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -1258,7 +1258,7 @@ class Catalog(Folder,
security.declarePrivate('catalogObjectList')
def catalogObjectList(self, object_list, method_id_list=None,
disable_cache=0, check_uid=1, idxs=None):
disable_cache=0, check_uid=1, idxs=None, deferred=0):
"""Add objects to the Catalog by calling all SQL methods and
providing needed arguments.
......@@ -1282,7 +1282,8 @@ class Catalog(Folder,
method_id_list=method_id_list,
disable_cache=disable_cache,
check_uid=check_uid,
idxs=idxs)
idxs=idxs,
deferred=deferred)
def getSqlCatalogObjectListList(self):
return self.sql_catalog_object_list
......@@ -1291,7 +1292,7 @@ class Catalog(Folder,
return self.sql_deferred_catalog_object_list
def _catalogObjectList(self, object_list, method_id_list=None,
disable_cache=0, check_uid=1, idxs=None):
disable_cache=0, check_uid=1, idxs=None, deferred=0):
"""This is the real method to catalog objects."""
if idxs not in (None, []):
LOG('ZSLQCatalog.SQLCatalog:catalogObjectList', WARNING,
......@@ -1358,7 +1359,10 @@ class Catalog(Folder,
LOG('SQLCatalog._catalogObjectList', ERROR, error_message)
if method_id_list is None:
method_id_list = self.getSqlCatalogObjectListList()
if deferred:
method_id_list = self.getSqlDeferredCatalogObjectListList()
else:
method_id_list = self.getSqlCatalogObjectListList()
econtext = getEngine().getContext()
if disable_cache:
argument_cache = DummyDict()
......
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