Commit 5884ed81 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use caching_instance_method decorator with a more efficient cache_id generator.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29776 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fe096a89
...@@ -38,7 +38,7 @@ from Products.ERP5Type.Globals import InitializeClass ...@@ -38,7 +38,7 @@ from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type.CopySupport import CopyContainer from Products.ERP5Type.CopySupport import CopyContainer
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Cache import caching_instance_method
from zLOG import LOG from zLOG import LOG
...@@ -127,15 +127,14 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool): ...@@ -127,15 +127,14 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool):
security.declareProtected(Permissions.AccessContentsInformation, 'getUids') security.declareProtected(Permissions.AccessContentsInformation, 'getUids')
getUids = getCategoryParentUidList getUids = getCategoryParentUidList
@caching_instance_method(id='portal_categories.getBaseCategoryDict', cache_factory='erp5_content_long', cache_id_generator=lambda m, *a, **k:m)
def getBaseCategoryDict(self): def getBaseCategoryDict(self):
""" """
Cached method to which resturns a dict with category names as keys, and None as values. Cached method to which resturns a dict with category names as keys, and None as values.
This allows to search for an element existence in the list faster. This allows to search for an element existence in the list faster.
ie: if x in self.getPortalObject().portal_categories.getBaseCategoryDict() ie: if x in self.getPortalObject().portal_categories.getBaseCategoryDict()
""" """
def getBaseCategoryDict(self): return dict.fromkeys(self.getBaseCategoryList(), None)
return dict.fromkeys(self.getBaseCategoryList(), None)
return CachingMethod(getBaseCategoryDict, 'portal_categories.getBaseCategoryDict', cache_factory='erp5_content_long')(self)
def updateRelatedContent(self, context, def updateRelatedContent(self, context,
previous_category_url, new_category_url): previous_category_url, new_category_url):
......
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