Commit 2ca1a5b9 authored by Nicolas Dumazet's avatar Nicolas Dumazet

Use a set instead of a list for repetitive lookups.

This should improve nicely BT Upgrade/Install step speed
(3 to 6 times faster for report creation?)



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33442 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c6aa35b4
...@@ -75,19 +75,19 @@ getModifiedObjectList = CachingMethod(getModifiedObjectList, \n ...@@ -75,19 +75,19 @@ getModifiedObjectList = CachingMethod(getModifiedObjectList, \n
id=\'BusinessTemplate_getModifiedObjectList\',\n id=\'BusinessTemplate_getModifiedObjectList\',\n
cache_factory=\'erp5_ui_medium\')\n cache_factory=\'erp5_ui_medium\')\n
\n \n
bt_objects = {}\n bt_object_dict = {}\n
\n \n
for bt_id in bt_id_list:\n for bt_id in bt_id_list:\n
bt = context.portal_templates[bt_id]\n bt = context.portal_templates[bt_id]\n
bt_objects[bt.getId()] = [bt.getTitle(), getModifiedObjectList(bt)]\n bt_object_dict[bt.getId()] = [bt.getTitle(), getModifiedObjectList(bt)]\n
\n \n
object_list = []\n object_list = []\n
no_backup_list = [\'Action\', \'SiteProperty\', \'Module\', \'Document\', \n no_backup_set = set([\'Action\', \'SiteProperty\', \'Module\', \'Document\', \n
\'PropertySheet\', \'Extension\', \'Test\', \'Product\', \n \'PropertySheet\', \'Extension\', \'Test\', \'Product\', \n
\'Role\', \'CatalogResultKey\', \'CatalogRelatedKey\', \n \'Role\', \'CatalogResultKey\', \'CatalogRelatedKey\', \n
\'CatalogResultTable\', \'MessageTranslation\', \'LocalRoles\', \n \'CatalogResultTable\', \'MessageTranslation\', \'LocalRoles\', \n
\'PortalTypeAllowedContentType\', \'PortalTypeHiddenContentType\', \n \'PortalTypeAllowedContentType\', \'PortalTypeHiddenContentType\', \n
\'PortalTypePropertySheet\', \'PortalTypeBaseCategory\']\n \'PortalTypePropertySheet\', \'PortalTypeBaseCategory\'])\n
\n \n
install_title = Base_translateString(\'Install\')\n install_title = Base_translateString(\'Install\')\n
upgrade_title = Base_translateString(\'Upgrade\')\n upgrade_title = Base_translateString(\'Upgrade\')\n
...@@ -96,51 +96,34 @@ remove_title = Base_translateString(\'Remove\')\n ...@@ -96,51 +96,34 @@ remove_title = Base_translateString(\'Remove\')\n
save_and_remove_title = Base_translateString(\'Backup And Remove\')\n save_and_remove_title = Base_translateString(\'Backup And Remove\')\n
\n \n
for bt in bt_id_list:\n for bt in bt_id_list:\n
modified_object_list = bt_objects[bt][1] \n bt_title, modified_object_list = bt_object_dict[bt]\n
bt_title = bt_objects[bt][0]\n
keys = modified_object_list.keys()\n keys = modified_object_list.keys()\n
keys.sort()\n keys.sort()\n
i = 0\n for i, object_id in enumerate(keys): \n
for object_id in keys: \n
object_state, object_class = modified_object_list[object_id]\n object_state, object_class = modified_object_list[object_id]\n
object_id = bt+\'|\'+object_id\n object_id = bt+\'|\'+object_id\n
line = newTempBase(context, \'tmp_install_%s\' %(str(i)))\n line = newTempBase(context, \'tmp_install_%s\' % i)\n
if object_state == \'New\':\n \n
line.edit(object_id=object_id,\n if object_state == \'Modified\':\n
bt_title = bt_title, \n if object_class in no_backup_set:\n
object_state=object_state, \n choice_item_list = [[upgrade_title, \'install\']]\n
object_class=object_class, \n
choice_item_list=[[install_title, \'install\']])\n
elif object_state == \'Modified\':\n
if object_class in no_backup_list:\n
line.edit(object_id=object_id, \n
bt_title = bt_title, \n
object_state=object_state, \n
object_class=object_class, \n
choice_item_list=[[upgrade_title, \'install\']])\n
else:\n else:\n
line.edit(object_id=object_id, \n choice_item_list = [[backup_title, \'backup\']]\n
bt_title = bt_title, \n
object_state=object_state, \n
object_class=object_class, \n
choice_item_list=[[backup_title, \'backup\']])\n
\n
elif object_state == \'Removed\':\n elif object_state == \'Removed\':\n
if object_class in no_backup_list:\n if object_class in no_backup_set:\n
line.edit(object_id=object_id, \n choice_item_list = [[remove_title, \'remove\']]\n
bt_title = bt_title, \n
object_state=object_state, \n
object_class=object_class, \n
choice_item_list=[[remove_title, \'remove\']])\n
else:\n else:\n
line.edit(object_id=object_id, \n choice_item_list = [[save_and_remove_title, \'save_and_remove\']]\n
bt_title = bt_title, \n else:\n
object_state=object_state, \n choice_item_list = [[install_title, \'install\']]\n
object_class=object_class, \n \n
choice_item_list=[[save_and_remove_title, \'save_and_remove\']])\n line.edit(object_id=object_id,\n
line.setUid(\'new_%s\' % str(object_id))\n bt_title = bt_title, \n
object_state=object_state, \n
object_class=object_class, \n
choice_item_list=choice_item_list)\n
line.setUid(\'new_%s\' % object_id)\n
object_list.append(line)\n object_list.append(line)\n
i += 1 \n
\n \n
object_list.sort(key=lambda x:(x.bt_title, x.object_class, x.object_state))\n object_list.sort(key=lambda x:(x.bt_title, x.object_class, x.object_state))\n
return object_list\n return object_list\n
...@@ -195,29 +178,30 @@ return object_list\n ...@@ -195,29 +178,30 @@ return object_list\n
<string>Products.ERP5Type.Cache</string> <string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string> <string>CachingMethod</string>
<string>getModifiedObjectList</string> <string>getModifiedObjectList</string>
<string>bt_objects</string> <string>bt_object_dict</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>bt_id</string> <string>bt_id</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>bt</string> <string>bt</string>
<string>_write_</string> <string>_write_</string>
<string>object_list</string> <string>object_list</string>
<string>no_backup_list</string> <string>set</string>
<string>no_backup_set</string>
<string>install_title</string> <string>install_title</string>
<string>upgrade_title</string> <string>upgrade_title</string>
<string>backup_title</string> <string>backup_title</string>
<string>remove_title</string> <string>remove_title</string>
<string>save_and_remove_title</string> <string>save_and_remove_title</string>
<string>modified_object_list</string>
<string>bt_title</string> <string>bt_title</string>
<string>modified_object_list</string>
<string>keys</string> <string>keys</string>
<string>enumerate</string>
<string>i</string> <string>i</string>
<string>object_id</string> <string>object_id</string>
<string>object_state</string> <string>object_state</string>
<string>object_class</string> <string>object_class</string>
<string>str</string>
<string>line</string> <string>line</string>
<string>_inplacevar_</string> <string>choice_item_list</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
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