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 @@ ...@@ -50,56 +50,40 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Utils import UpperCase\n <value> <string>restrictedTraverse = context.getPortalObject().restrictedTraverse\n
from ZODB.POSException import ConflictError\n argument_getter_dict = {}\n
# XXX à refaire pour optimisation\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 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 parameter_dict = {}\n
failed_path_list = []\n for property in method.arguments_src.split():\n
restrictedTraverse = context.getPortalObject().restrictedTraverse\n parameter_dict[property] = parameter_value_list = []\n
subscription = restrictedTraverse(subscription_path)\n if property == \'getData\':\n
for path in path_list:\n getter = getData\n
obj = restrictedTraverse(path, None)\n elif property == \'getId\':\n
try:\n getter = getId\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
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 else:\n
for property, value in tmp_dict.items():\n getter = None\n
parameter_dict.setdefault(property, []).append(value)\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 \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 \n
if parameter_dict:\n parameter_dict, parameter_append_list = generateParameterList()\n
return method(**parameter_dict)\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> </string> </value>
</item> </item>
<item> <item>
......
...@@ -62,7 +62,7 @@ WHERE\n ...@@ -62,7 +62,7 @@ WHERE\n
AND gid >= <dtml-sqlvar min_gid type="string">\n AND gid >= <dtml-sqlvar min_gid type="string">\n
</dtml-if>\n </dtml-if>\n
<dtml-if max_gid>\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 </dtml-if>\n
......
114 115
\ No newline at end of file \ 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