Commit 9fda5829 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

make erp5_full_text_sphinxse_catalog more consistent with erp5_full_text_myisam_catalog.

parent 7c0c216d
...@@ -50,10 +50,9 @@ ...@@ -50,10 +50,9 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string># This script is called to separate SphinxSE indexing into a low-priority active object,\n <value> <string># This script is called to defer fulltext indexing in a lower priority.\n
# so that the important part can be finished quickly and also to serialise it because\n # Activities are serialised because concurrent write may cause crash of searchd.\n
# concurrent write may cause crash of searchd.\n context.activate(activity=\'SQLQueue\', priority=4, serialization_tag=\'sphinxse_indexing\').SQLCatalog_deferFullTextIndexActivity(path_list=list(getPath))\n
context.activate(activity=\'SQLQueue\', priority=3, serialization_tag=\'sphinxse_indexing\').SQLCatalog_catalogSphinxSE(getPath=getPath)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -62,7 +61,7 @@ context.activate(activity=\'SQLQueue\', priority=3, serialization_tag=\'sphinxse ...@@ -62,7 +61,7 @@ context.activate(activity=\'SQLQueue\', priority=3, serialization_tag=\'sphinxse
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SQLCatalog_deferSphinxSEIndexing</string> </value> <value> <string>SQLCatalog_deferFullTextIndex</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -52,34 +52,20 @@ ...@@ -52,34 +52,20 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Utils import UpperCase\n <value> <string>from Products.ERP5Type.Utils import UpperCase\n
from ZODB.POSException import ConflictError\n from ZODB.POSException import ConflictError\n
from zExceptions import Unauthorized\n
\n \n
# Retrieves SearchableText from catalog\n method = context.z_catalog_fulltext_list\n
method = context.z_catalog_sphinxse_index_list\n method2 = context.z_catalog_sphinxse_index_list\n
parameter_dict = {\'uid\':[], \'SearchableText\':[]}\n
for i in context.getPortalObject().portal_catalog(path=getPath, select_expression=\'SearchableText\'):\n
for property in (\'uid\', \'SearchableText\'):\n
parameter_dict[property].append(getattr(i, property))\n
if len(parameter_dict[\'uid\']):\n
return method(**parameter_dict)\n
return\n
\n
# the following is the alternate version that fails in case of errors (eg. NotConvertedError).\n
# if we separate updating full_text table activities too, we can consider using this one.\n
\n
# Obtain the properties from the Z SQL Method itself, as like catalogObjectList.\n
method = context.z_catalog_sphinxse_index_list\n
property_list = method.arguments_src.split()\n property_list = method.arguments_src.split()\n
\n
# This below emulates what catalogObjectList is doing.\n
portal = context.getPortalObject()\n
document_type_list = portal.getPortalDocumentTypeList()\n
parameter_dict = {}\n parameter_dict = {}\n
failed_path_list = []\n failed_path_list = []\n
for path in getPath:\n restrictedTraverse = context.getPortalObject().restrictedTraverse\n
obj = portal.restrictedTraverse(path, None)\n for path in path_list:\n
if not path: # should happen in tricky testERP5Catalog tests only \n
continue\n
obj = restrictedTraverse(path, None)\n
if obj is None:\n if obj is None:\n
continue\n continue\n
\n
try:\n try:\n
tmp_dict = {}\n tmp_dict = {}\n
for property in property_list:\n for property in property_list:\n
...@@ -90,7 +76,10 @@ for path in getPath:\n ...@@ -90,7 +76,10 @@ for path in getPath:\n
tmp_dict[property] = value\n tmp_dict[property] = value\n
except ConflictError:\n except ConflictError:\n
raise\n raise\n
except:\n except Unauthorized: # should happen in tricky testERP5Catalog tests only \n
continue\n
except Exception, e:\n
exception = e\n
failed_path_list.append(path)\n failed_path_list.append(path)\n
else:\n else:\n
for property, value in tmp_dict.items():\n for property, value in tmp_dict.items():\n
...@@ -99,30 +88,23 @@ for path in getPath:\n ...@@ -99,30 +88,23 @@ for path in getPath:\n
if len(failed_path_list):\n if len(failed_path_list):\n
if len(parameter_dict):\n if len(parameter_dict):\n
# reregister activity for failed objects only\n # reregister activity for failed objects only\n
context.activate(activity=\'SQLQueue\', priority=5, serialization_tag=\'sphinxse_indexing\').SQLCatalog_catalogSphinxSE(getPath=failed_path_list)\n context.activate(activity=\'SQLQueue\', priority=5, serialization_tag=\'sphinxse_indexing\').SQLCatalog_deferFullTextIndexActivity(path_list=failed_path_list)\n
else:\n else:\n
# if all objects are failed one, just raise an exception to avoid infinite loop.\n # if all objects are failed one, just raise an exception to avoid infinite loop.\n
raise AttributeError, \'exception raised in indexing %r\' % failed_path_list\n raise AttributeError, \'exception %r raised in indexing %r\' % (exception, failed_path_list)\n
\n \n
if len(parameter_dict):\n if parameter_dict:\n
return method(**parameter_dict)\n method(**parameter_dict)\n
method2(**parameter_dict)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>getPath</string> </value> <value> <string>path_list</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SQLCatalog_catalogSphinxSE</string> </value> <value> <string>SQLCatalog_deferFullTextIndexActivity</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<catalog_method> <catalog_method>
<item key="sql_catalog_object_list" type="int">
<value>1</value>
</item>
</catalog_method> </catalog_method>
...@@ -60,7 +60,7 @@ while True:\n ...@@ -60,7 +60,7 @@ while True:\n
full_text_list = portal_catalog(limit=(i*LIMIT, LIMIT))\n full_text_list = portal_catalog(limit=(i*LIMIT, LIMIT))\n
if len(full_text_list) == 0:\n if len(full_text_list) == 0:\n
break\n break\n
sql_catalog.SQLCatalog_deferSphinxSEIndexing(getPath=[x.path for x in full_text_list])\n sql_catalog.SQLCatalog_deferFullTextIndex(getPath=[x.path for x in full_text_list])\n
i += 1\n i += 1\n
return \'SphinxSE index will be updated in background.\'\n return \'SphinxSE index will be updated in background.\'\n
</string> </value> </string> </value>
......
erp5_mysql_innodb/SQLCatalog_catalogSphinxSE erp5_mysql_innodb/SQLCatalog_deferFullTextIndex
erp5_mysql_innodb/SQLCatalog_deferSphinxSEIndexing erp5_mysql_innodb/SQLCatalog_deferFullTextIndexActivity
erp5_mysql_innodb/SQLCatalog_makeFullTextQuery erp5_mysql_innodb/SQLCatalog_makeFullTextQuery
erp5_mysql_innodb/z0_drop_fulltext erp5_mysql_innodb/z0_drop_fulltext
erp5_mysql_innodb/z0_drop_sphinxse_index erp5_mysql_innodb/z0_drop_sphinxse_index
......
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