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>
......
......@@ -3,7 +3,7 @@
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="StringField" module="Products.Formulator.StandardFields"/>
<global name="EditorField" module="Products.ERP5Form.EditorField"/>
<tuple/>
</tuple>
</pickle>
......@@ -21,13 +21,21 @@
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>line_too_long</string> </key>
<value> <string>A line was too long.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>Too much input was given.</string> </value>
<value> <string>You entered too many characters.</string> </value>
</item>
<item>
<key> <string>too_many_lines</string> </key>
<value> <string>You entered too many lines.</string> </value>
</item>
</dictionary>
</value>
......@@ -52,14 +60,6 @@
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
......@@ -76,6 +76,10 @@
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
......@@ -84,16 +88,24 @@
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<key> <string>text_editor</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
......@@ -104,6 +116,10 @@
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -127,23 +143,13 @@
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
......@@ -153,6 +159,10 @@
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
......@@ -161,16 +171,24 @@
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<key> <string>text_editor</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
......@@ -181,6 +199,10 @@
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -208,14 +230,6 @@ You can find an OpenOffice template at <a href="openoffice-erp5-objects-template
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
......@@ -232,6 +246,10 @@ You can find an OpenOffice template at <a href="openoffice-erp5-objects-template
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>5</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
......@@ -240,47 +258,40 @@ You can find an OpenOffice template at <a href="openoffice-erp5-objects-template
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OpenOffice Source File Example</string> </value>
<key> <string>text_editor</string> </key>
<value> <string>text_area</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <int>0</int> </value>
<key> <string>title</string> </key>
<value> <string>OpenOffice Source File Example</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>1</int> </value>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
<item>
<key> <string>width</string> </key>
<value> <int>40</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: not here.REQUEST.get(\'OOOIMPORT_STEP_TWO\', False)</string> </value>
</value>
</item>
</dictionary>
</pickle>
......
......@@ -3,7 +3,7 @@
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="StringField" module="Products.Formulator.StandardFields"/>
<global name="EditorField" module="Products.ERP5Form.EditorField"/>
<tuple/>
</tuple>
</pickle>
......@@ -21,13 +21,21 @@
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>line_too_long</string> </key>
<value> <string>A line was too long.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>Too much input was given.</string> </value>
<value> <string>You entered too many characters.</string> </value>
</item>
<item>
<key> <string>too_many_lines</string> </key>
<value> <string>You entered too many lines.</string> </value>
</item>
</dictionary>
</value>
......@@ -52,14 +60,6 @@
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
......@@ -76,6 +76,10 @@
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
......@@ -84,16 +88,24 @@
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<key> <string>text_editor</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
......@@ -104,6 +116,10 @@
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -127,23 +143,13 @@
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
......@@ -153,6 +159,10 @@
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
......@@ -161,16 +171,24 @@
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<key> <string>text_editor</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
......@@ -181,6 +199,10 @@
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -208,21 +230,13 @@
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
......@@ -232,6 +246,10 @@
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>5</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
......@@ -240,47 +258,40 @@
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Warning</string> </value>
<key> <string>text_editor</string> </key>
<value> <string>text_area</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <int>0</int> </value>
<key> <string>title</string> </key>
<value> <string>Warning</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>1</int> </value>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
<item>
<key> <string>width</string> </key>
<value> <int>40</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.REQUEST.get(\'OOOIMPORT_STEP_TWO\', False)</string> </value>
</value>
</item>
</dictionary>
</pickle>
......
......@@ -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