Commit eec88b7b authored by Jérome Perrin's avatar Jérome Perrin

use getProperty / setProperty instead of old style computting the getter / setter name

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14693 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 07aa662d
...@@ -71,7 +71,6 @@ ...@@ -71,7 +71,6 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
from Products.ERP5OOo.OOoUtils import OOoParser\n from Products.ERP5OOo.OOoUtils import OOoParser\n
from Products.ERP5Type.Utils import convertToUpperCase\n
OOoParser = OOoParser()\n OOoParser = OOoParser()\n
\n \n
\n \n
...@@ -81,7 +80,7 @@ def getIDFromString(string=None):\n ...@@ -81,7 +80,7 @@ def getIDFromString(string=None):\n
This function transform a string to a safe and beautiful ID.\n This function transform a string to a safe and beautiful ID.\n
It is used here to create a safe category ID from a string.\n It is used here to create a safe category ID from a string.\n
"""\n """\n
if string == None:\n if string is None:\n
return None\n return None\n
clean_id = \'\'\n clean_id = \'\'\n
translation_map = { \'a\' : [u\'\\xe0\', u\'\\xe3\']\n translation_map = { \'a\' : [u\'\\xe0\', u\'\\xe3\']\n
...@@ -149,7 +148,8 @@ for table_name in spreadsheets.keys():\n ...@@ -149,7 +148,8 @@ for table_name in spreadsheets.keys():\n
# else : The path definition is not started or is finished, so ignore the column\n # else : The path definition is not started or is finished, so ignore the column\n
# The column has a normal header\n # The column has a normal header\n
else:\n else:\n
# If there is a new column with a header and the path definition has started, that seems the path definition has ended\n # If there is a new column with a header and the path definition has\n
# started, that seems the path definition has ended\n
if \'path_0\' in property_map.values():\n if \'path_0\' in property_map.values():\n
path_index == None\n path_index == None\n
property_map[column_index] = column_id\n property_map[column_index] = column_id\n
...@@ -274,28 +274,22 @@ for table_name in spreadsheets.keys():\n ...@@ -274,28 +274,22 @@ for table_name in spreadsheets.keys():\n
# Set the category properties\n # Set the category properties\n
for key in keys:\n for key in keys:\n
if key not in [\'path\', \'id\']:\n if key not in [\'path\', \'id\']:\n
setter_method_id = "set" + convertToUpperCase(key)\n
getter_method_id = "get" + convertToUpperCase(key)\n
value = category[key]\n value = category[key]\n
if value not in (\'\', None):\n if value not in (\'\', None):\n
# Get the current value of the attribute\n # Get the current value of the attribute\n
if hasattr(new_category, getter_method_id):\n previous_value = new_category.getProperty(key)\n
getter = getattr(new_category, getter_method_id)\n new_value = value.encode(\'UTF-8\')\n
previous_value = getter()\n # Do not update or set object attribute if the vale remain the same.\n
new_value = value.encode(\'UTF-8\')\n if previous_value != new_value:\n
# Do not update or set object attribute if the vale remain the same.\n new_category.setProperty(key, new_value)\n
if previous_value != new_value:\n # Update statistics\n
if hasattr(new_category, setter_method_id):\n if not is_new_category:\n
setter = getattr(new_category, setter_method_id)\n updated_category_counter += 1\n
setter(new_value)\n
# Update statistics\n
if not is_new_category:\n
updated_category_counter += 1\n
\n
\n \n
\n \n
# Import is a success, go back to the portal_categories tool\n # Import is a success, go back to the portal_categories tool\n
return context.REQUEST.RESPONSE.redirect(\n return context.REQUEST.RESPONSE.redirect(\n
# TODO translate\n
"%s/view?portal_status_message=%s+categories+found+in+%s+:+%s+created,+%s+updated,+%s+untouched."\n "%s/view?portal_status_message=%s+categories+found+in+%s+:+%s+created,+%s+updated,+%s+untouched."\n
% ( context.portal_categories.absolute_url()\n % ( context.portal_categories.absolute_url()\n
, total_category_counter\n , total_category_counter\n
...@@ -353,8 +347,6 @@ return context.REQUEST.RESPONSE.redirect(\n ...@@ -353,8 +347,6 @@ return context.REQUEST.RESPONSE.redirect(\n
<string>kw</string> <string>kw</string>
<string>Products.ERP5OOo.OOoUtils</string> <string>Products.ERP5OOo.OOoUtils</string>
<string>OOoParser</string> <string>OOoParser</string>
<string>Products.ERP5Type.Utils</string>
<string>convertToUpperCase</string>
<string>None</string> <string>None</string>
<string>getIDFromString</string> <string>getIDFromString</string>
<string>_getattr_</string> <string>_getattr_</string>
...@@ -409,15 +401,9 @@ return context.REQUEST.RESPONSE.redirect(\n ...@@ -409,15 +401,9 @@ return context.REQUEST.RESPONSE.redirect(\n
<string>category_type</string> <string>category_type</string>
<string>new_category</string> <string>new_category</string>
<string>key</string> <string>key</string>
<string>setter_method_id</string>
<string>getter_method_id</string>
<string>value</string> <string>value</string>
<string>hasattr</string>
<string>getattr</string>
<string>getter</string>
<string>previous_value</string> <string>previous_value</string>
<string>new_value</string> <string>new_value</string>
<string>setter</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
341 342
\ 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