From 089ed5a2faa6daf6ab0f66e1b1db186d6679b126 Mon Sep 17 00:00:00 2001 From: Fabien Morin <fabien@nexedi.com> Date: Wed, 7 Jan 2009 17:27:24 +0000 Subject: [PATCH] 2009-01-07 fabien * update some scripts used to generate domain to display planningbox. This permit to increase the speed of the page displaying (about 3 time faster in my tests) git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25033 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../TaskModule_generatePersonDomain.xml | 57 ++++++---- .../TaskModule_generateProjectDomain.xml | 107 ++++++++++++------ .../TaskReportModule_generatePersonDomain.xml | 57 ++++++---- ...TaskReportModule_generateProjectDomain.xml | 107 ++++++++++++------ bt5/erp5_project/bt/change_log | 3 + bt5/erp5_project/bt/revision | 2 +- 6 files changed, 222 insertions(+), 111 deletions(-) diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generatePersonDomain.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generatePersonDomain.xml index a69bda9085..fb1e534a08 100644 --- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generatePersonDomain.xml +++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generatePersonDomain.xml @@ -53,26 +53,37 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>request = context.REQUEST\n -domain_list = []\n + <value> <string>domain_list = []\n \n if depth == 0:\n - category_list = [ ]\n - for i in context.portal_selections.getSelectionValueList(context=context,\n - selection_name= \'task_module_selection\'):\n - category_list.extend([j for j in i.getSourceValueList() if j not in category_list])\n -\n -\n + task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name=\'task_module_selection\')\n + person_result = context.portal_catalog(portal_type=["Person",],\n + source_related_uid=task_uid_list,\n + select_expression=\'catalog.portal_type, catalog.relative_url, catalog.id, catalog.title\',\n + sort_on = ((\'title\',\'ascending\'),))\n + person_dict = {}\n + person_list = []\n + append = person_list.append\n + for person in person_result:\n + key = person.uid\n + if key not in person_dict:\n + person_dict[key] = None\n + category_dict = {\'relative_url\':person.relative_url, \n + \'portal_type\':person.portal_type,\n + \'id\':person.id,\n + \'title\':person.title,\n + \'uid\':person.uid}\n + append(category_dict)\n else:\n return domain_list\n \n -for category in category_list:\n - domain = parent.generateTempDomain(id = \'sub\' + category.getId() )\n - domain.edit(title = category.getTitle(),\n +for person in person_list:\n + domain = parent.generateTempDomain(id = \'sub\' + person[\'id\'] )\n + domain.edit(title = person[\'title\'],\n membership_criterion_base_category = (\'source\', ), \n - membership_criterion_category = (category.getRelativeUrl(),),\n + membership_criterion_category = (person[\'relative_url\'],),\n domain_generator_method_id = script.id,\n - uid = category.getUid())\n + uid = person[\'uid\'])\n \n domain_list.append(domain)\n \n @@ -116,17 +127,21 @@ return domain_list\n <string>depth</string> <string>parent</string> <string>kw</string> + <string>domain_list</string> <string>_getattr_</string> <string>context</string> - <string>request</string> - <string>domain_list</string> - <string>category_list</string> - <string>_getiter_</string> - <string>i</string> + <string>task_uid_list</string> + <string>person_result</string> + <string>person_dict</string> + <string>person_list</string> <string>append</string> - <string>$append0</string> - <string>j</string> - <string>category</string> + <string>_getiter_</string> + <string>person</string> + <string>key</string> + <string>None</string> + <string>_write_</string> + <string>category_dict</string> + <string>_getitem_</string> <string>domain</string> <string>script</string> </tuple> diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generateProjectDomain.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generateProjectDomain.xml index d7781a2b49..72ceeea545 100644 --- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generateProjectDomain.xml +++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskModule_generateProjectDomain.xml @@ -53,44 +53,86 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>request = context.REQUEST\n + <value> <string encoding="cdata"><![CDATA[ + +restrictedTraverse = context.getPortalObject().restrictedTraverse\n domain_list = []\n \n +def Task_getRelatedSourceProject(depth, parent_relative_url=None):\n + if depth == 0:\n + task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name=\'task_module_selection\')\n + project_result = context.portal_catalog(portal_type=["Project", "Project Line"],\n + source_project_related_uid=task_uid_list,\n + select_expression=\'catalog.portal_type, catalog.relative_url, catalog.id, catalog.title\',\n + sort_on = ((\'title\',\'ascending\'),))\n + else:\n + project_result = context.portal_catalog(portal_type=["Project Line", "Project Milestones"],\n + select_expression=\'catalog.portal_type, catalog.relative_url, catalog.id, catalog.title\',\n + parent_relative_url=parent_relative_url,\n + sort_on = ((\'title\',\'ascending\'),))\n + # use a dict to store catalog result\n + project_dict = {}\n + category_dict = {}\n + project_list = []\n + append = project_list.append\n + for x in project_result:\n + key = x.uid\n + if key not in project_dict:\n + project_dict[key] = None\n + category_dict = {\'relative_url\':x.relative_url, \n + \'portal_type\':x.portal_type,\n + \'id\':x.id,\n + \'title\':x.title,\n + \'uid\':x.uid}\n + append(category_dict)\n + \n + return project_list\n \n -if depth == 0:\n - category_list = []\n - for task in context.portal_selections.getSelectionValueList(context=context,\n - selection_name=\'task_module_selection\'):\n - source_project_value_list = \\\n - task.getSourceProjectValueList(portal_type=["Project", "Project Line"])\n - for source_project_value in source_project_value_list:\n - if source_project_value.getPortalType() == \'Project\':\n - category = source_project_value\n - else:\n - category = source_project_value.getExplanationValue()\n - if category not in category_list:\n - category_list.append(category)\n - \n -else:\n +def Task_getRelatedSourceProjectCategory(depth):\n + parent_relative_url = None\n + if depth > 0:\n + parent_relative_url = parent.getMembershipCriterionCategoryList()\n + project_list = Task_getRelatedSourceProject(depth=depth,\n + parent_relative_url=parent_relative_url)\n +\n + category_dict = {}\n category_list = []\n - for i in context.portal_selections.getSelectionValueList(context=context,\n - selection_name=\'task_module_selection\'):\n - category_list.extend([j for j in i.getSourceProjectValueList(portal_type=["Project Line", "Project Milestones"]) \\\n - if (j not in category_list) and (j.getParentRelativeUrl() in parent.getMembershipCriterionCategoryList())])\n + append = category_list.append\n +\n + for project in project_list:\n + if project[\'portal_type\'] == \'Project\' or depth > 0:\n + category = project\n + else:\n + # XXX here we need to get the project line object to get the explanation value\n + project_line_value = restrictedTraverse(project[\'relative_url\'])\n + explanation_value = project_line_value.getExplanationValue()\n + category = {\'relative_url\':explanation_value.getRelativeUrl(), \n + \'portal_type\':explanation_value.getPortalType(),\n + \'id\':explanation_value.getId(),\n + \'title\':explanation_value.getTitle(),\n + \'uid\':explanation_value.getUid()}\n + key = category[\'uid\']\n + if key not in category_dict:\n + category_dict[key] = None\n + append(category)\n \n + return category_list\n +\n +category_list = Task_getRelatedSourceProjectCategory(depth)\n \n for category in category_list:\n - domain = parent.generateTempDomain(id = \'sub\' + category.getId() )\n - domain.edit(title = category.getTitle(),\n + domain = parent.generateTempDomain(id = \'sub\' + category[\'id\'] )\n + domain.edit(title = category[\'title\'],\n membership_criterion_base_category = (\'source_project\', ), \n - membership_criterion_category = (category.getRelativeUrl(),),\n + membership_criterion_category = (category[\'relative_url\'],),\n domain_generator_method_id = script.id,\n - uid = category.getUid())\n + uid = category[\'uid\'])\n \n domain_list.append(domain)\n -\n return domain_list\n -</string> </value> + + +]]></string> </value> </item> <item> <key> <string>_code</string> </key> @@ -131,18 +173,15 @@ return domain_list\n <string>kw</string> <string>_getattr_</string> <string>context</string> - <string>request</string> + <string>restrictedTraverse</string> <string>domain_list</string> + <string>None</string> + <string>Task_getRelatedSourceProject</string> + <string>Task_getRelatedSourceProjectCategory</string> <string>category_list</string> <string>_getiter_</string> - <string>task</string> - <string>source_project_value_list</string> - <string>source_project_value</string> <string>category</string> - <string>i</string> - <string>append</string> - <string>$append0</string> - <string>j</string> + <string>_getitem_</string> <string>domain</string> <string>script</string> </tuple> diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReportModule_generatePersonDomain.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReportModule_generatePersonDomain.xml index 65b0118a15..48541b3ffc 100644 --- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReportModule_generatePersonDomain.xml +++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReportModule_generatePersonDomain.xml @@ -53,26 +53,37 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>request = context.REQUEST\n -domain_list = []\n + <value> <string>domain_list = []\n \n if depth == 0:\n - category_list = [ ]\n - for i in context.portal_selections.getSelectionValueList(context=context,\n - selection_name= \'task_report_module_selection\'):\n - category_list.extend([j for j in i.getSourceValueList() if j not in category_list])\n -\n -\n + task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name=\'task_report_module_selection\')\n + person_result = context.portal_catalog(portal_type=["Person",],\n + source_related_uid=task_uid_list,\n + select_expression=\'catalog.portal_type, catalog.relative_url, catalog.id, catalog.title\',\n + sort_on = ((\'title\',\'ascending\'),))\n + person_dict = {}\n + person_list = []\n + append = person_list.append\n + for person in person_result:\n + key = person.uid\n + if key not in person_dict:\n + person_dict[key] = None\n + category_dict = {\'relative_url\':person.relative_url, \n + \'portal_type\':person.portal_type,\n + \'id\':person.id,\n + \'title\':person.title,\n + \'uid\':person.uid}\n + append(category_dict)\n else:\n return domain_list\n \n -for category in category_list:\n - domain = parent.generateTempDomain(id = \'sub\' + category.getId() )\n - domain.edit(title = category.getTitle(),\n +for person in person_list:\n + domain = parent.generateTempDomain(id = \'sub\' + person[\'id\'] )\n + domain.edit(title = person[\'title\'],\n membership_criterion_base_category = (\'source\', ), \n - membership_criterion_category = (category.getRelativeUrl(),),\n + membership_criterion_category = (person[\'relative_url\'],),\n domain_generator_method_id = script.id,\n - uid = category.getUid())\n + uid = person[\'uid\'])\n \n domain_list.append(domain)\n \n @@ -116,17 +127,21 @@ return domain_list\n <string>depth</string> <string>parent</string> <string>kw</string> + <string>domain_list</string> <string>_getattr_</string> <string>context</string> - <string>request</string> - <string>domain_list</string> - <string>category_list</string> - <string>_getiter_</string> - <string>i</string> + <string>task_uid_list</string> + <string>person_result</string> + <string>person_dict</string> + <string>person_list</string> <string>append</string> - <string>$append0</string> - <string>j</string> - <string>category</string> + <string>_getiter_</string> + <string>person</string> + <string>key</string> + <string>None</string> + <string>_write_</string> + <string>category_dict</string> + <string>_getitem_</string> <string>domain</string> <string>script</string> </tuple> diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReportModule_generateProjectDomain.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReportModule_generateProjectDomain.xml index 898b02b8fd..c1d7bc1642 100644 --- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReportModule_generateProjectDomain.xml +++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReportModule_generateProjectDomain.xml @@ -53,44 +53,86 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>request = context.REQUEST\n + <value> <string encoding="cdata"><![CDATA[ + +restrictedTraverse = context.getPortalObject().restrictedTraverse\n domain_list = []\n \n +def Task_getRelatedSourceProject(depth, parent_relative_url=None):\n + if depth == 0:\n + task_uid_list = context.portal_selections.getSelectionUidList(context=context, selection_name=\'task_report_module_selection\')\n + project_result = context.portal_catalog(portal_type=["Project", "Project Line"],\n + source_project_related_uid=task_uid_list,\n + select_expression=\'catalog.portal_type, catalog.relative_url, catalog.id, catalog.title\',\n + sort_on = ((\'title\',\'ascending\'),))\n + else:\n + project_result = context.portal_catalog(portal_type=["Project Line", "Project Milestones"],\n + select_expression=\'catalog.portal_type, catalog.relative_url, catalog.id, catalog.title\',\n + parent_relative_url=parent_relative_url,\n + sort_on = ((\'title\',\'ascending\'),))\n + # use a dict to store catalog result\n + project_dict = {}\n + category_dict = {}\n + project_list = []\n + append = project_list.append\n + for x in project_result:\n + key = x.uid\n + if key not in project_dict:\n + project_dict[key] = None\n + category_dict = {\'relative_url\':x.relative_url, \n + \'portal_type\':x.portal_type,\n + \'id\':x.id,\n + \'title\':x.title,\n + \'uid\':x.uid}\n + append(category_dict)\n + \n + return project_list\n \n -if depth == 0:\n - category_list = []\n - for task in context.portal_selections.getSelectionValueList(context=context,\n - selection_name=\'task_report_module_selection\'):\n - source_project_value_list = \\\n - task.getSourceProjectValueList(portal_type=["Project", "Project Line"])\n - for source_project_value in source_project_value_list:\n - if source_project_value.getPortalType() == \'Project\':\n - category = source_project_value\n - else:\n - category = source_project_value.getExplanationValue()\n - if category not in category_list:\n - category_list.append(category)\n - \n -else:\n +def Task_getRelatedSourceProjectCategory(depth):\n + parent_relative_url = None\n + if depth > 0:\n + parent_relative_url = parent.getMembershipCriterionCategoryList()\n + project_list = Task_getRelatedSourceProject(depth=depth,\n + parent_relative_url=parent_relative_url)\n +\n + category_dict = {}\n category_list = []\n - for i in context.portal_selections.getSelectionValueList(context=context,\n - selection_name=\'task_report_module_selection\'):\n - category_list.extend([j for j in i.getSourceProjectValueList(portal_type=["Project Line", "Project Milestones"]) \\\n - if (j not in category_list) and (j.getParentRelativeUrl() in parent.getMembershipCriterionCategoryList())])\n + append = category_list.append\n +\n + for project in project_list:\n + if project[\'portal_type\'] == \'Project\' or depth > 0:\n + category = project\n + else:\n + # XXX here we need to get the project line object to get the explanation value\n + project_line_value = restrictedTraverse(project[\'relative_url\'])\n + explanation_value = project_line_value.getExplanationValue()\n + category = {\'relative_url\':explanation_value.getRelativeUrl(), \n + \'portal_type\':explanation_value.getPortalType(),\n + \'id\':explanation_value.getId(),\n + \'title\':explanation_value.getTitle(),\n + \'uid\':explanation_value.getUid()}\n + key = category[\'uid\']\n + if key not in category_dict:\n + category_dict[key] = None\n + append(category)\n \n + return category_list\n +\n +category_list = Task_getRelatedSourceProjectCategory(depth)\n \n for category in category_list:\n - domain = parent.generateTempDomain(id = \'sub\' + category.getId() )\n - domain.edit(title = category.getTitle(),\n + domain = parent.generateTempDomain(id = \'sub\' + category[\'id\'] )\n + domain.edit(title = category[\'title\'],\n membership_criterion_base_category = (\'source_project\', ), \n - membership_criterion_category = (category.getRelativeUrl(),),\n + membership_criterion_category = (category[\'relative_url\'],),\n domain_generator_method_id = script.id,\n - uid = category.getUid())\n + uid = category[\'uid\'])\n \n domain_list.append(domain)\n -\n return domain_list\n -</string> </value> + + +]]></string> </value> </item> <item> <key> <string>_code</string> </key> @@ -131,18 +173,15 @@ return domain_list\n <string>kw</string> <string>_getattr_</string> <string>context</string> - <string>request</string> + <string>restrictedTraverse</string> <string>domain_list</string> + <string>None</string> + <string>Task_getRelatedSourceProject</string> + <string>Task_getRelatedSourceProjectCategory</string> <string>category_list</string> <string>_getiter_</string> - <string>task</string> - <string>source_project_value_list</string> - <string>source_project_value</string> <string>category</string> - <string>i</string> - <string>append</string> - <string>$append0</string> - <string>j</string> + <string>_getitem_</string> <string>domain</string> <string>script</string> </tuple> diff --git a/bt5/erp5_project/bt/change_log b/bt5/erp5_project/bt/change_log index 34896daf66..b54315e6b0 100644 --- a/bt5/erp5_project/bt/change_log +++ b/bt5/erp5_project/bt/change_log @@ -1,3 +1,6 @@ +2009-01-07 fabien +* update some scripts used to generate domain to display planningbox. This permit to increase the speed of the page displaying (about 3 time faster in my tests) + 2008-10-07 yusei * Update field titles for translation. diff --git a/bt5/erp5_project/bt/revision b/bt5/erp5_project/bt/revision index e25083957d..c8a110e7e8 100644 --- a/bt5/erp5_project/bt/revision +++ b/bt5/erp5_project/bt/revision @@ -1 +1 @@ -618 \ No newline at end of file +621 \ No newline at end of file -- 2.30.9