Commit 83209e46 authored by Vincent Pelletier's avatar Vincent Pelletier

Add a cache on getDocumentTemplateList.

Fix caches in SQLCatalog no to pass self as a parameter. 


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9888 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dceb4c68
......@@ -185,19 +185,22 @@ class PreferenceTool(BaseTool):
""" returns all document templates that are in acceptable Preferences
based on different criteria such as folder, portal_type, etc.
"""
if folder is None :
# as the preference tool is also a Folder, this method is called by
# page templates to get the list of document templates for self.
folder = self
acceptable_templates = []
allowed_content_types = map(lambda pti: pti.id,
folder.allowedContentTypes())
for pref in self._getSortedPreferenceList() :
for doc in pref.objectValues() :
if doc.getPortalType() in allowed_content_types:
acceptable_templates.append (doc)
return acceptable_templates
def _getDocumentTemplateList(folder=None):
if folder is None :
# as the preference tool is also a Folder, this method is called by
# page templates to get the list of document templates for self.
folder = self
acceptable_templates = []
allowed_content_types = map(lambda pti: pti.id,
folder.allowedContentTypes())
for pref in self._getSortedPreferenceList() :
for doc in pref.objectValues() :
if doc.getPortalType() in allowed_content_types:
acceptable_templates.append (doc)
return acceptable_templates
return CachingMethod(_getDocumentTemplateList, 'portal_preferences.getDocumentTemplateList', cache_duration=3000)(folder)
InitializeClass(PreferenceTool)
......@@ -739,7 +739,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
Calls the show column method and returns dictionnary of
Field Ids
"""
def _getColumnIds(self):
def _getColumnIds():
keys = {}
for table in self.getCatalogSearchTableIds():
field_list = self._getCatalogSchema(table=table)
......@@ -753,14 +753,14 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
keys = keys.keys()
keys.sort()
return keys
return CachingMethod(_getColumnIds, id='SQLCatalog.getColumnIds', cache_duration=None)(self)
return CachingMethod(_getColumnIds, id='SQLCatalog.getColumnIds', cache_duration=None)()
def getColumnMap(self):
"""
Calls the show column method and returns dictionnary of
Field Ids
"""
def _getColumnMap(self):
def _getColumnMap():
keys = {}
for table in self.getCatalogSearchTableIds():
field_list = self._getCatalogSchema(table=table)
......@@ -772,7 +772,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
if not keys.has_key(key): keys[key] = []
keys[key].append(table) # Is this inconsistent ?
return keys
return CachingMethod(_getColumnMap, id='SQLCatalog.getColumnMap', cache_duration=None)(self)
return CachingMethod(_getColumnMap, id='SQLCatalog.getColumnMap', cache_duration=None)()
def getResultColumnIds(self):
"""
......
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