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,6 +185,7 @@ class PreferenceTool(BaseTool): ...@@ -185,6 +185,7 @@ 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.
""" """
def _getDocumentTemplateList(folder=None):
if folder is None : if folder is None :
# as the preference tool is also a Folder, this method is called by # as the preference tool is also a Folder, this method is called by
# page templates to get the list of document templates for self. # page templates to get the list of document templates for self.
...@@ -199,5 +200,7 @@ class PreferenceTool(BaseTool): ...@@ -199,5 +200,7 @@ class PreferenceTool(BaseTool):
acceptable_templates.append (doc) acceptable_templates.append (doc)
return acceptable_templates 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