[Erp5-report] r9888 - in /erp5/trunk/products: ERP5Form/ ZSQLCatalog/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Sep 13 17:28:48 CEST 2006
Author: vincent
Date: Wed Sep 13 17:28:46 2006
New Revision: 9888
URL: http://svn.erp5.org?rev=9888&view=rev
Log:
Add a cache on getDocumentTemplateList.
Fix caches in SQLCatalog no to pass self as a parameter.
Modified:
erp5/trunk/products/ERP5Form/PreferenceTool.py
erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
Modified: erp5/trunk/products/ERP5Form/PreferenceTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/PreferenceTool.py?rev=9888&r1=9887&r2=9888&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/PreferenceTool.py (original)
+++ erp5/trunk/products/ERP5Form/PreferenceTool.py Wed Sep 13 17:28:46 2006
@@ -185,19 +185,22 @@
""" 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)
Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=9888&r1=9887&r2=9888&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py Wed Sep 13 17:28:46 2006
@@ -739,7 +739,7 @@
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 @@
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 @@
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):
"""
More information about the Erp5-report
mailing list