Commit a790de2b authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

* use 'key in dict' instead of 'key in dict.keys()'.

* use xrange() instead of range().
* do not display portal_type id in property mapping listbox for better usability.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26036 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b20ef16d
......@@ -62,11 +62,10 @@ for portal_type in module.allowedContentTypes():\n
#property_string = "%s.%s" % (portal_type.id, property[\'id\'])\n
#property_list.append(property_string)\n
for property in portal_type.getInstancePropertyAndBaseCategoryList():\n
property_string = "%s.%s" % (portal_type.id, property)\n
property_list.append(property_string)\n
property_list.append((portal_type.id, property))\n
\n
property_list.sort()\n
return [(\'-- Ignore this Property --\', \'\')] + map(lambda x: (x,x), property_list)\n
return [(\'-- Ignore this Property --\', \'\')] + map(lambda x: (x[1], \'%s.%s\' % (x[0], x[1])), property_list)\n
</string> </value>
</item>
<item>
......@@ -110,7 +109,6 @@ return [(\'-- Ignore this Property --\', \'\')] + map(lambda x: (x,x), property_
<string>_getattr_</string>
<string>portal_type</string>
<string>property</string>
<string>property_string</string>
<string>map</string>
</tuple>
</value>
......
......@@ -53,9 +53,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
<value> <string>"""\n
This script is an alpha version of what should be a generic OpenOffice importer,\n
which is a collection of scripts and UI to import lots of objects to ERP5\n
from a spreadsheet. The idea is to let the user map each spreadsheet column with\n
......@@ -127,7 +125,7 @@ else:\n
map_item = { \'portal_type\': portal_type_property.split(\'.\')[0]\n
, \'property\' : portal_type_property.split(\'.\')[1]\n
}\n
if spreadsheet_name not in mapping.keys():\n
if spreadsheet_name not in mapping:\n
mapping[spreadsheet_name] = {}\n
mapping[spreadsheet_name][column_name] = map_item\n
\n
......@@ -139,7 +137,7 @@ else:\n
\n
# Build a data structure to associate column index with column title\n
column_index = {}\n
for column_id in range(len(sheet_data[0])):\n
for column_id in xrange(len(sheet_data[0])):\n
column_index[column_id] = sheet_data[0][column_id]\n
\n
# Build a data structure to associate column index with object property and portal type\n
......@@ -154,8 +152,8 @@ else:\n
object_list = {}\n
for line in sheet_data[1:]:\n
new_object_property_dict = {}\n
for line_property_index in range(len(line)):\n
if line_property_index in column_mapping.keys():\n
for line_property_index in xrange(len(line)):\n
if line_property_index in column_mapping:\n
property_module = sheet_module\n
property_module_url = property_module.getRelativeUrl()\n
property_pt = column_mapping[line_property_index][\'portal_type\']\n
......@@ -171,7 +169,7 @@ else:\n
# Create a new property value\n
new_object_property_dict[property_id] = property_value\n
\n
if len(new_object_property_dict.keys()) > 0:\n
if new_object_property_dict:\n
object_list[property_module_url][property_pt].append(new_object_property_dict)\n
\n
context.activate(tag="object_OOo_import", priority=1, activity="SQLQueue").ERP5Site_importObjectFromOOoActivity(object_list=object_list)\n
......@@ -179,9 +177,7 @@ else:\n
return request.RESPONSE.redirect(context.absolute_url() + \'/view?portal_status_message=OpenOffice+document+importing.\')\n
\n
return context.ERP5Site_importObjectFromOOoFastInput(REQUEST=request)\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -248,7 +244,7 @@ return context.ERP5Site_importObjectFromOOoFastInput(REQUEST=request)\n
<string>sheet_data</string>
<string>sheet_module</string>
<string>column_index</string>
<string>range</string>
<string>xrange</string>
<string>column_id</string>
<string>column_mapping</string>
<string>property_dict</string>
......
......@@ -9,6 +9,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts47455675.31</string> </value>
......
550
\ No newline at end of file
551
\ 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