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