From 44e6a06c91e713c0ebc9e6f57f145ba99013b1fd Mon Sep 17 00:00:00 2001 From: Yusei Tahara <yusei@nexedi.com> Date: Tue, 8 Jun 2010 12:36:13 +0000 Subject: [PATCH] 2010-06-08 yusei * Add CategoryTool_getPreferredPredicateCategoryParentUidItemList for optimized predicate category search. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36093 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...rredPredicateCategoryParentUidItemList.xml | 165 ++++++++++++++++++ .../ERP5/bootstrap/erp5_core/bt/change_log | 3 + product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- 3 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CategoryTool_getPreferredPredicateCategoryParentUidItemList.xml diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CategoryTool_getPreferredPredicateCategoryParentUidItemList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CategoryTool_getPreferredPredicateCategoryParentUidItemList.xml new file mode 100644 index 0000000000..fac6e62c4a --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CategoryTool_getPreferredPredicateCategoryParentUidItemList.xml @@ -0,0 +1,165 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </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>#\n +# This script is used by portal_catalog/erp5_mysql_innodb/z_catalog_predicate_category_list\n +#\n +enabled_base_category_list = document.getBaseCategoryList()\n +\n +preferred_predicate_category_list = context.portal_preferences.getPreferredPredicateCategoryList()\n +\n +category_parent_uid_item_list = context.getCategoryParentUidList(membership_criterion_category_list)\n +\n +if not preferred_predicate_category_list:\n + return category_parent_uid_item_list\n +\n +# category_parent_uid_item_list structure is (category_uid, base_category_uid, category_strict_membership)\n +category_parent_uid_item_dict = dict([(item[1], item) for item in category_parent_uid_item_list])\n +\n +for base_category_id in preferred_predicate_category_list:\n + base_category = getattr(context, base_category_id, None)\n + if base_category is None:\n + pass\n + base_category_uid = base_category.getUid()\n +\n + if not base_category_uid in category_parent_uid_item_dict and base_category_id in enabled_base_category_list:\n + # Add an empty record only if document does not have the category value and the category is enabled on the document.\n + category_parent_uid_item_dict[base_category_uid] = [0, base_category_uid, 1]\n +\n +return category_parent_uid_item_dict.values()\n +</string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>membership_criterion_category_list, document</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>2</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>membership_criterion_category_list</string> + <string>document</string> + <string>_getattr_</string> + <string>enabled_base_category_list</string> + <string>context</string> + <string>preferred_predicate_category_list</string> + <string>category_parent_uid_item_list</string> + <string>dict</string> + <string>append</string> + <string>$append0</string> + <string>_getiter_</string> + <string>item</string> + <string>_getitem_</string> + <string>category_parent_uid_item_dict</string> + <string>base_category_id</string> + <string>getattr</string> + <string>None</string> + <string>base_category</string> + <string>base_category_uid</string> + <string>_write_</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>CategoryTool_getPreferredPredicateCategoryParentUidItemList</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/product/ERP5/bootstrap/erp5_core/bt/change_log b/product/ERP5/bootstrap/erp5_core/bt/change_log index 1b32a6d379..4b6347e684 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/change_log +++ b/product/ERP5/bootstrap/erp5_core/bt/change_log @@ -1,3 +1,6 @@ +2010-06-08 yusei +* Add CategoryTool_getPreferredPredicateCategoryParentUidItemList for optimized predicate category search. + 2010-06-04 yo * Do not enable reindexing by default. Who has approved such a change? It is up to the system administrator to decide when the catalog can be cleared. diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index f5624aeaec..54d8728c18 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -1600 \ No newline at end of file +1601 \ No newline at end of file -- 2.30.9