Commit 4057fd51 authored by Aurel's avatar Aurel

rewrite indexation method (done by vincent) & fix sql condition to prevent overriding

parent c820b88e
......@@ -50,56 +50,40 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Utils import UpperCase\n
from ZODB.POSException import ConflictError\n
# XXX à refaire pour optimisation\n
<value> <string>restrictedTraverse = context.getPortalObject().restrictedTraverse\n
argument_getter_dict = {}\n
if subscription_path:\n
subscription = restrictedTraverse(subscription_path)\n
getId = subscription.getGidFromObject\n
getData = subscription.getDataFromDocument\n
else:\n
getId = getData = None\n
\n
method = context.z_catalog_syncml_document_list\n
property_list = method.arguments_src.split()\n
\n
parameter_append_list = []\n
append = parameter_append_list.append\n
parameter_dict = {}\n
failed_path_list = []\n
restrictedTraverse = context.getPortalObject().restrictedTraverse\n
subscription = restrictedTraverse(subscription_path)\n
for path in path_list:\n
obj = restrictedTraverse(path, None)\n
try:\n
tmp_dict = {}\n
for property in property_list:\n
if subscription_path:\n
if property == "gid": \n
# Call specific method to compute GID on source data\n
value = subscription.getGidFromObject(obj)\n
elif property == "data":\n
value = subscription.getDataFromDocument(obj)\n
else:\n
value = getattr(obj, \'get%s\' % UpperCase(property))() \n
for property in method.arguments_src.split():\n
parameter_dict[property] = parameter_value_list = []\n
if property == \'getData\':\n
getter = getData\n
elif property == \'getId\':\n
getter = getId\n
else:\n
if property == "gid":\n
# Signature GID is defined as its ID\n
value = getattr(obj, \'getId\')()\n
else:\n
value = getattr(obj, \'get%s\' % UpperCase(property))()\n
tmp_dict[property] = value\n
except ConflictError:\n
raise\n
except Exception, e:\n
raise\n
exception = e\n
failed_path_list.append(path)\n
else:\n
for property, value in tmp_dict.items():\n
parameter_dict.setdefault(property, []).append(value)\n
getter = None\n
if getter is None:\n
getter = lambda obj, property=property: getattr(obj, property)()\n
append((parameter_value_list, getter))\n
return parameter_dict, parameter_append_list\n
\n
if len(failed_path_list):\n
if len(parameter_dict):\n
# reregister activity for failed objects only\n
activate_kw.update(activity=\'SQLQueue\', priority=5)\n
context.activate(**activate_kw).SQLCatalog_indexSyncMLSignatureList(path_list=failed_path_list)\n
else:\n
# if all objects are failed one, just raise an exception to avoid infinite loop.\n
raise AttributeError, \'exception %r raised in indexing %r\' % (exception, failed_path_list)\n
\n
if parameter_dict:\n
return method(**parameter_dict)\n
parameter_dict, parameter_append_list = generateParameterList()\n
for path in path_list:\n
obj = restrictedTraverse(path)\n
for value_list, getter in parameter_append_list:\n
value_list.append(getter(obj))\n
method(**parameter_dict)\n
</string> </value>
</item>
<item>
......
......@@ -62,7 +62,7 @@ WHERE\n
AND gid >= <dtml-sqlvar min_gid type="string">\n
</dtml-if>\n
<dtml-if max_gid>\n
AND gid <= <dtml-sqlvar max_gid type="string">\n
AND gid < <dtml-sqlvar max_gid type="string">\n
</dtml-if>\n
......
114
\ No newline at end of file
115
\ No newline at end of file
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