[Erp5-report] r13899 - in /erp5/trunk/bt5/erp5_base: SkinTemplateItem/portal_skins/erp5_bas...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Apr 3 16:05:10 CEST 2007


Author: nicolas
Date: Tue Apr  3 16:05:05 2007
New Revision: 13899

URL: http://svn.erp5.org?rev=13899&view=rev
Log:
Nicolas
* Import Object from OOo use activities

Added:
    erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOoActivity.xml
Modified:
    erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOo.xml
    erp5/trunk/bt5/erp5_base/bt/revision

Modified: erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOo.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOo.xml?rev=13899&r1=13898&r2=13899&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOo.xml (original)
+++ erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOo.xml Tue Apr  3 16:05:05 2007
@@ -81,6 +81,7 @@
     * ERP5Site_importObjectFromOOoFastInput          -- The UI\n
     * ERP5Site_getSpreadsheetColumnNameList          -- Utility script\n
     * ERP5Site_getModulePortalTypeSortedPropertyList -- Utility script\n
+    * ERP5Site_importObjectFromOOoActivity           -- Activating Import Script\n
 """\n
 \n
 request  = context.REQUEST\n
@@ -92,7 +93,7 @@
   return map(lambda x: x[1], rq.items())\n
 \n
 def getSpreadsheet():\n
-  from Products.ERP5OOo.OOoUtils import OOoParser\n
+  from Products.ERP5OOo.OOoUtils import OOoParser, CorruptedOOoFile\n
   OOoParser = OOoParser()\n
   # Extract tables from the speadsheet file\n
   import_file = kw[\'import_file\']\n
@@ -117,13 +118,13 @@
 \n
 # Second Step\n
 else:\n
-\n
   # Re-upload the OOo file\n
   spreadsheets = getSpreadsheet()\n
 \n
   # Build the data mapping\n
   mapping = {}\n
   request.set(\'ooo_import_spreadsheet_data\', spreadsheets)\n
+\n
   listbox_ordered_lines = context.ERP5Site_getSpreadsheetColumnNameList()\n
   for line in listbox_ordered_lines:\n
     listbox_id = line.getUid()[4:]\n
@@ -171,51 +172,29 @@
       for line_property_index in range(len(line)):\n
         if line_property_index in column_mapping.keys():\n
           property_module = sheet_module\n
+          property_module_url = property_module.getRelativeUrl()\n
           property_pt     = column_mapping[line_property_index][\'portal_type\']\n
           property_id     = column_mapping[line_property_index][\'property\']\n
           property_value  = line[line_property_index]\n
 \n
           if not property_value in (\'\', None):\n
-            if not object_list.has_key(property_module):\n
-              object_list[property_module] = {}\n
-            if not object_list[property_module].has_key(property_pt):\n
-              object_list[property_module][property_pt] = []\n
+            if not object_list.has_key(property_module_url):\n
+              object_list[property_module_url] = {}\n
+            if not object_list[property_module_url].has_key(property_pt):\n
+              object_list[property_module_url][property_pt] = []\n
   \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
-        object_list[property_module][property_pt].append(new_object_property_dict)\n
-  # Create new ERP5 objects\n
-  new_path_list = []\n
-  for (module, per_portal_type_data) in object_list.items():\n
-    for (portal_type, new_object_list) in per_portal_type_data.items():\n
-      for new_object_property_dict in new_object_list:\n
-        #get portal type objects\n
-        ptype_object = None\n
-        for allowed_ptype in module.allowedContentTypes():\n
-          ptype_name = \'\'.join(allowed_ptype.id.split(\' \'))\n
-          if ptype_name == portal_type:\n
-            ptype_object = allowed_ptype\n
-            break\n
-        if ptype_object is None:\n
-          raise \'Portal type %s not found in allowed content types\' % portal_type\n
-        category_list = ptype_object.getInstanceBaseCategoryList()\n
-        new_object = module.newContent( portal_type       = portal_type\n
-                                      , immediate_reindex = 1\n
-                                      )\n
-        new_object_category_dict = {}\n
-        for prop_key in new_object_property_dict.keys():\n
-          if prop_key in category_list:\n
-            new_object_category_dict[prop_key] = new_object_property_dict[prop_key]\n
-            del new_object_property_dict[prop_key]\n
-        new_object.edit(**new_object_property_dict)\n
-        # Match the categories\n
-        new_object_category_dict = context.ERP5Site_getCategoriesFullPath(category_dict = new_object_category_dict)\n
-        new_object.edit(**new_object_category_dict)\n
-        new_path_list.append(new_object.getRelativeUrl())\n
-  \n
-  return request.RESPONSE.redirect(context.absolute_url() + \'/person_module/view?portal_status_message=OpenOffice+document+successfully+imported.+New+object+created:+\' + str(len(new_path_list)))\n
+        object_list[property_module_url][property_pt].append(new_object_property_dict)\n
+    if len(object_list) % 100 == 0 :\n
+      context.activate(tag="object_OOo_import", priority=1, activity="SQLQueue").ERP5Site_importObjectFromOOoActivity(object_list=object_list)\n
+      object_list = []\n
+\n
+    # rest of activities\n
+    context.activate(tag="object_OOo_import", priority=1, activity="SQLQueue").ERP5Site_importObjectFromOOoActivity(object_list=object_list)\n
+  return request.RESPONSE.redirect(context.absolute_url() + \'/view?portal_status_message=OpenOffice+document+importing.\')\n
 \n
 return context.ERP5Site_importObjectFromOOoFastInput(REQUEST=request)\n
 
@@ -308,23 +287,10 @@
                             <string>new_object_property_dict</string>
                             <string>line_property_index</string>
                             <string>property_module</string>
+                            <string>property_module_url</string>
                             <string>property_pt</string>
                             <string>property_id</string>
                             <string>property_value</string>
-                            <string>new_path_list</string>
-                            <string>module</string>
-                            <string>per_portal_type_data</string>
-                            <string>portal_type</string>
-                            <string>new_object_list</string>
-                            <string>ptype_object</string>
-                            <string>allowed_ptype</string>
-                            <string>ptype_name</string>
-                            <string>category_list</string>
-                            <string>new_object</string>
-                            <string>new_object_category_dict</string>
-                            <string>prop_key</string>
-                            <string>_apply_</string>
-                            <string>str</string>
                           </tuple>
                         </value>
                     </item>

Added: erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOoActivity.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOoActivity.xml?rev=13899&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOoActivity.xml (added)
+++ erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_importObjectFromOOoActivity.xml Tue Apr  3 16:05:05 2007
@@ -1,0 +1,197 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.PythonScripts.PythonScript</string>
+          <string>PythonScript</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Python_magic</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string># Create new ERP5 objects In Activity from OOo document\n
+context.log(\'object_list\',object_list)\n
+context.log(\'kw\',kw)\n
+for (module_url, per_portal_type_data) in object_list.items():\n
+  for (portal_type, new_object_list) in per_portal_type_data.items():\n
+    for new_object_property_dict in new_object_list:\n
+      #get portal type objects\n
+      ptype_object = None\n
+      module = context.getPortalObject().restrictedTraverse(module_url)\n
+      for allowed_ptype in module.allowedContentTypes():\n
+        ptype_name = \'\'.join(allowed_ptype.id.split(\' \'))\n
+        if ptype_name == portal_type:\n
+          ptype_object = allowed_ptype\n
+          break\n
+      if ptype_object is None:\n
+        raise \'Portal type %s not found in allowed content types\' % portal_type\n
+      category_list = ptype_object.getInstanceBaseCategoryList()\n
+      new_object = module.newContent( portal_type       = portal_type\n
+                                    , immediate_reindex = 1\n
+                                    )\n
+      new_object_category_dict = {}\n
+      for prop_key in new_object_property_dict.keys():\n
+        if prop_key in category_list:\n
+          new_object_category_dict[prop_key] = new_object_property_dict[prop_key]\n
+          del new_object_property_dict[prop_key]\n
+      new_object.edit(**new_object_property_dict)\n
+      # Match the categories\n
+      new_object_category_dict = context.ERP5Site_getCategoriesFullPath(category_dict = new_object_category_dict)\n
+      new_object.edit(**new_object_category_dict)\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_filepath</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>object_list, **kw</string> </value>
+        </item>
+        <item>
+            <key> <string>errors</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_code</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>co_argcount</string> </key>
+                        <value> <int>1</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>object_list</string>
+                            <string>kw</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>_getiter_</string>
+                            <string>module_url</string>
+                            <string>per_portal_type_data</string>
+                            <string>portal_type</string>
+                            <string>new_object_list</string>
+                            <string>new_object_property_dict</string>
+                            <string>None</string>
+                            <string>ptype_object</string>
+                            <string>module</string>
+                            <string>allowed_ptype</string>
+                            <string>ptype_name</string>
+                            <string>category_list</string>
+                            <string>new_object</string>
+                            <string>new_object_category_dict</string>
+                            <string>prop_key</string>
+                            <string>_getitem_</string>
+                            <string>_write_</string>
+                            <string>_apply_</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>ERP5Site_importObjectFromOOoActivity</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Modified: erp5/trunk/bt5/erp5_base/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/bt/revision?rev=13899&r1=13898&r2=13899&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/bt/revision (original)
+++ erp5/trunk/bt5/erp5_base/bt/revision Tue Apr  3 16:05:05 2007
@@ -1,1 +1,1 @@
-101
+41




More information about the Erp5-report mailing list