Commit 09991337 authored by Sebastien Robin's avatar Sebastien Robin

2009-01-23 Seb

* Fixed date problems with ERP5Site_checkCatalogTable
* ERP5Site_getStockTableFilterDict must now returns a dictionnary of values instead of a dictionnary of methods

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25284 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 53e88a07
...@@ -66,13 +66,8 @@ ...@@ -66,13 +66,8 @@
Offset the bundle, to allow walking along the catalog with\n Offset the bundle, to allow walking along the catalog with\n
bundle_object_count increment.\n bundle_object_count increment.\n
property_override_method_id\n property_override_method_id\n
Id of a method generating a property_override_dict as described below and\n Id of a method that generates a dictionary of reference values\n
returning it.\n for a particular item in the catalog.\n
property_override_dict (key: catalog column id, value: method id)\n
Defines custom methods to calculate reference column value.\n
None means that the column is not checked at all.\n
Otherwise, the function will be called on the object with no parameter\n
and must return the reference value for the column.\n
catalog_kw\n catalog_kw\n
Extra parameters passed to catalog\n Extra parameters passed to catalog\n
retry\n retry\n
...@@ -88,10 +83,8 @@ result_list = []\n ...@@ -88,10 +83,8 @@ result_list = []\n
if catalog_kw is None:\n if catalog_kw is None:\n
catalog_kw = {}\n catalog_kw = {}\n
\n \n
if property_override_method_id is None:\n if not catalog_kw.has_key(\'sort_on\'):\n
property_override_dict = {}\n catalog_kw[\'sort_on\'] = ((\'uid\',\'ascending\'),)\n
else:\n
property_override_dict = getattr(context, property_override_method_id)()\n
\n \n
if catalog_uid_list is None:\n if catalog_uid_list is None:\n
# No uid list was given: fetch work to do from catalog and spawn activities\n # No uid list was given: fetch work to do from catalog and spawn activities\n
...@@ -101,7 +94,9 @@ if catalog_uid_list is None:\n ...@@ -101,7 +94,9 @@ if catalog_uid_list is None:\n
if uid_min is not None:\n if uid_min is not None:\n
# Check what is after last check\n # Check what is after last check\n
catalog_kw[\'uid\'] = {\'query\': uid_min, \'range\': \'nlt\'}\n catalog_kw[\'uid\'] = {\'query\': uid_min, \'range\': \'nlt\'}\n
catalog_uid_list = [x.uid for x in context.portal_catalog(limit=bundle_object_count * activity_count, **catalog_kw)]\n catalog_uid_list = [x.uid for x in context.portal_catalog(\n
limit=bundle_object_count * activity_count, \n
**catalog_kw)]\n
context.log(\'sql src\', context.portal_catalog(limit=bundle_object_count * activity_count, src__=1, **catalog_kw))\n context.log(\'sql src\', context.portal_catalog(limit=bundle_object_count * activity_count, src__=1, **catalog_kw))\n
if len(catalog_uid_list):\n if len(catalog_uid_list):\n
# Get the last uid this pass will check, so that next pass will check a batch starting after this uid.\n # Get the last uid this pass will check, so that next pass will check a batch starting after this uid.\n
...@@ -177,26 +172,27 @@ else:\n ...@@ -177,26 +172,27 @@ else:\n
or (getattr(actual_object, \'getExplanationValue\', None) is not None \\\n or (getattr(actual_object, \'getExplanationValue\', None) is not None \\\n
and actual_object.getExplanationValue().hasActivity()):\n and actual_object.getExplanationValue().hasActivity()):\n
continue\n continue\n
if property_override_method_id is None:\n
reference_dict = {}\n
else:\n
reference_dict = getattr(context, property_override_method_id)(instance=actual_object)\n
for attribute_id in attribute_id_list:\n for attribute_id in attribute_id_list:\n
override_method_id = property_override_dict.get(attribute_id, MARKER)\n if not reference_dict.has_key(attribute_id):\n
if override_method_id is None:\n reference_value = actual_object.getProperty(attribute_id)\n
continue\n
elif override_method_id is MARKER:\n
reference_value = actual_object.getProperty(key=attribute_id)\n
elif same_type(override_method_id, \'\'):\n
reference_value = getattr(actual_object, override_method_id)()\n
else:\n else:\n
reference_value = override_method_id(instance=actual_object)\n reference_value = reference_dict[attribute_id]\n
catalog_value = catalog_line[attribute_id]\n catalog_value = catalog_line[attribute_id]\n
if same_type(catalog_value, REFERENCE_DATETIME):\n
catalog_value = DateTime(catalog_value.Date())\n
reference_can_be_null_value = False\n reference_can_be_null_value = False\n
if same_type(reference_value, tuple()) or same_type(reference_value, list()):\n if same_type(reference_value, tuple()) or same_type(reference_value, list()):\n
for reference_value_item in reference_value:\n for reference_value_item in reference_value:\n
# We probably do not need this\n
if same_type(reference_value, REFERENCE_DATETIME):\n
reference_value = DateTime("%s Universal" % reference_value.toZone("Universal").ISO())\n
if reference_value_item in null_value_list:\n if reference_value_item in null_value_list:\n
reference_can_be_null_value = True\n reference_can_be_null_value = True\n
break\n
else:\n else:\n
if same_type(reference_value, REFERENCE_DATETIME):\n
reference_value = DateTime("%s Universal" % reference_value.toZone("Universal").ISO())\n
if reference_value in null_value_list:\n if reference_value in null_value_list:\n
reference_can_be_null_value = True\n reference_can_be_null_value = True\n
if reference_can_be_null_value and catalog_value in null_value_list:\n if reference_can_be_null_value and catalog_value in null_value_list:\n
...@@ -216,6 +212,7 @@ else:\n ...@@ -216,6 +212,7 @@ else:\n
message = \'%s.%s = %s, but catalog contains %s\' % (actual_object.getRelativeUrl(), attribute_id,\n message = \'%s.%s = %s, but catalog contains %s\' % (actual_object.getRelativeUrl(), attribute_id,\n
repr(reference_value), repr(catalog_value))\n repr(reference_value), repr(catalog_value))\n
result_list.append(message)\n result_list.append(message)\n
\n
summary_list = []\n summary_list = []\n
begin = catalog_uid_list[0]\n begin = catalog_uid_list[0]\n
end = catalog_uid_list[-1]\n end = catalog_uid_list[-1]\n
...@@ -309,11 +306,9 @@ return active_result\n ...@@ -309,11 +306,9 @@ return active_result\n
<string>active_context</string> <string>active_context</string>
<string>result_list</string> <string>result_list</string>
<string>None</string> <string>None</string>
<string>property_override_dict</string> <string>_write_</string>
<string>getattr</string>
<string>first_run</string> <string>first_run</string>
<string>sql_kw</string> <string>sql_kw</string>
<string>_write_</string>
<string>append</string> <string>append</string>
<string>$append0</string> <string>$append0</string>
<string>_getiter_</string> <string>_getiter_</string>
...@@ -340,13 +335,14 @@ return active_result\n ...@@ -340,13 +335,14 @@ return active_result\n
<string>message</string> <string>message</string>
<string>actual_object</string> <string>actual_object</string>
<string>KeyError</string> <string>KeyError</string>
<string>getattr</string>
<string>reference_dict</string>
<string>attribute_id</string> <string>attribute_id</string>
<string>override_method_id</string>
<string>reference_value</string> <string>reference_value</string>
<string>same_type</string>
<string>catalog_value</string> <string>catalog_value</string>
<string>False</string> <string>False</string>
<string>reference_can_be_null_value</string> <string>reference_can_be_null_value</string>
<string>same_type</string>
<string>tuple</string> <string>tuple</string>
<string>list</string> <string>list</string>
<string>reference_value_item</string> <string>reference_value_item</string>
......
...@@ -94,16 +94,16 @@ def getQuantity(instance):\n ...@@ -94,16 +94,16 @@ def getQuantity(instance):\n
return (quantity, -quantity)\n return (quantity, -quantity)\n
\n \n
return {\n return {\n
\'node_uid\': getSourceAndDestinationList,\n \'node_uid\': getSourceAndDestinationList(instance),\n
\'payment_uid\': getSourcePaymentAndDestinationPaymentList,\n \'payment_uid\': getSourcePaymentAndDestinationPaymentList(instance),\n
\'section_uid\': getSourceSectionAndDestinationSectionList,\n \'section_uid\': getSourceSectionAndDestinationSectionList(instance),\n
\'mirror_section_uid\': getSourceSectionAndDestinationSectionList,\n \'mirror_section_uid\': getSourceSectionAndDestinationSectionList(instance),\n
\'date\': getStartDateAndStopDate,\n \'date\': getStartDateAndStopDate(instance),\n
\'mirror_date\': getStartDateAndStopDate,\n \'mirror_date\': getStartDateAndStopDate(instance),\n
\'total_price\': getTotalPrice,\n \'total_price\': getTotalPrice(instance),\n
\'quantity\': getQuantity,\n \'quantity\': getQuantity(instance),\n
\'mirror_node_uid\': getSourceAndDestinationList,\n \'mirror_node_uid\': getSourceAndDestinationList(instance),\n
\'simulation_state\': getSimulationState,\n \'simulation_state\': getSimulationState(instance),\n
}\n }\n
</string> </value> </string> </value>
</item> </item>
...@@ -115,7 +115,7 @@ return {\n ...@@ -115,7 +115,7 @@ return {\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>instance = None</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -135,12 +135,13 @@ return {\n ...@@ -135,12 +135,13 @@ return {\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>0</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>instance</string>
<string>DateTime</string> <string>DateTime</string>
<string>getSourceAndDestinationList</string> <string>getSourceAndDestinationList</string>
<string>getSourcePaymentAndDestinationPaymentList</string> <string>getSourcePaymentAndDestinationPaymentList</string>
...@@ -161,7 +162,9 @@ return {\n ...@@ -161,7 +162,9 @@ return {\n
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<tuple>
<none/> <none/>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
35 40
\ 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