Commit bb1a3bf2 authored by Aurel's avatar Aurel

define cache factory

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13084 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7b418fdb
...@@ -86,7 +86,8 @@ def getFieldDescription():\n ...@@ -86,7 +86,8 @@ def getFieldDescription():\n
return property.get(\'description\', \'\')\n return property.get(\'description\', \'\')\n
return desc\n return desc\n
\n \n
getFieldDescription = CachingMethod(getFieldDescription, (\'getFieldDescription\', form_id, field_id), cache_duration=None)\n getFieldDescription = CachingMethod(getFieldDescription, (\'getFieldDescription\', form_id, field_id), \\\n
cache_factory=\'erp5_user_interface_long\')\n
\n \n
return getFieldDescription()\n return getFieldDescription()\n
</string> </value> </string> </value>
...@@ -144,7 +145,6 @@ return getFieldDescription()\n ...@@ -144,7 +145,6 @@ return getFieldDescription()\n
<string>_getattr_</string> <string>_getattr_</string>
<string>field_id</string> <string>field_id</string>
<string>getFieldDescription</string> <string>getFieldDescription</string>
<string>None</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -74,7 +74,7 @@ navigation_box_render = CachingMethod(navigation_box_render,\n ...@@ -74,7 +74,7 @@ navigation_box_render = CachingMethod(navigation_box_render,\n
("ERP5Site_renderCachedNavigationBox",\n ("ERP5Site_renderCachedNavigationBox",\n
context.portal_membership.getAuthenticatedMember().getUserName(),\n context.portal_membership.getAuthenticatedMember().getUserName(),\n
context.Localizer.get_selected_language()\n context.Localizer.get_selected_language()\n
),cache_duration=300)\n ),cache_factory=\'erp5_user_interface_short\')\n
return navigation_box_render()\n return navigation_box_render()\n
</string> </value> </string> </value>
</item> </item>
......
...@@ -122,7 +122,7 @@ def getFormGroupTitleAndId():\n ...@@ -122,7 +122,7 @@ def getFormGroupTitleAndId():\n
\n \n
getFormGroupTitleAndId = CachingMethod(getFormGroupTitleAndId,\n getFormGroupTitleAndId = CachingMethod(getFormGroupTitleAndId,\n
("ERP5Site_getFormGroupTitleAndId", form.id, form.get_groups(include_empty=0)),\n ("ERP5Site_getFormGroupTitleAndId", form.id, form.get_groups(include_empty=0)),\n
cache_duration=None)\n cache_factory=\'erp5_user_interface_long\')\n
return getFormGroupTitleAndId()\n return getFormGroupTitleAndId()\n
</string> </value> </string> </value>
</item> </item>
...@@ -178,7 +178,6 @@ return getFormGroupTitleAndId()\n ...@@ -178,7 +178,6 @@ return getFormGroupTitleAndId()\n
<string>form</string> <string>form</string>
<string>getFormGroupTitleAndId</string> <string>getFormGroupTitleAndId</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>None</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
340 345
\ No newline at end of file \ No newline at end of file
...@@ -140,7 +140,8 @@ class PreferenceMethod(Method) : ...@@ -140,7 +140,8 @@ class PreferenceMethod(Method) :
if found : if found :
return value return value
_getPreference = CachingMethod( _getPreference, _getPreference = CachingMethod( _getPreference,
id='PreferenceTool.CachingMethod.%s' % self._preference_name) id='PreferenceTool.CachingMethod.%s' % self._preference_name,
cache_factory='erp5_user_interface_short')
user_name = getSecurityManager().getUser().getId() user_name = getSecurityManager().getUser().getId()
return _getPreference(user_name=user_name) return _getPreference(user_name=user_name)
...@@ -236,7 +237,7 @@ class PreferenceTool(BaseTool): ...@@ -236,7 +237,7 @@ class PreferenceTool(BaseTool):
return acceptable_templates return acceptable_templates
_getDocumentTemplateList = CachingMethod(_getDocumentTemplateList, _getDocumentTemplateList = CachingMethod(_getDocumentTemplateList,
'portal_preferences.getDocumentTemplateList', 'portal_preferences.getDocumentTemplateList',
cache_duration=3000) cache_factory='erp5_user_interface_medium')
allowed_content_types = map(lambda pti: pti.id, allowed_content_types = map(lambda pti: pti.id,
folder.allowedContentTypes()) folder.allowedContentTypes())
......
...@@ -233,7 +233,8 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -233,7 +233,8 @@ class OOoDocument(File, ConversionCacheMixin):
return [[y,x] for x,y in allowed] # have to reverse tuple order return [[y,x] for x,y in allowed] # have to reverse tuple order
cached_getTargetFormatItemList = CachingMethod(cached_getTargetFormatItemList, cached_getTargetFormatItemList = CachingMethod(cached_getTargetFormatItemList,
id = "OOoDocument_getTargetFormatItemList" ) id = "OOoDocument_getTargetFormatItemList",
cache_factory='erp5_core_short')
return cached_getTargetFormatItemList(self.getContentType()) return cached_getTargetFormatItemList(self.getContentType())
security.declareProtected(Permissions.AccessContentsInformation, 'getTargetFormatList') security.declareProtected(Permissions.AccessContentsInformation, 'getTargetFormatList')
......
...@@ -179,7 +179,8 @@ class ERP5GroupManager(BasePlugin): ...@@ -179,7 +179,8 @@ class ERP5GroupManager(BasePlugin):
if not NO_CACHE_MODE: if not NO_CACHE_MODE:
_getGroupsForPrincipal = CachingMethod(_getGroupsForPrincipal, _getGroupsForPrincipal = CachingMethod(_getGroupsForPrincipal,
id='ERP5GroupManager_getGroupsForPrincipal') id='ERP5GroupManager_getGroupsForPrincipal',
cache_factory='erp5_core_short')
return _getGroupsForPrincipal( return _getGroupsForPrincipal(
user_name=principal.getId(), user_name=principal.getId(),
......
...@@ -108,7 +108,8 @@ class ERP5UserManager(BasePlugin): ...@@ -108,7 +108,8 @@ class ERP5UserManager(BasePlugin):
return None return None
_authenticateCredentials = CachingMethod(_authenticateCredentials, _authenticateCredentials = CachingMethod(_authenticateCredentials,
id='ERP5UserManager_authenticateCredentials') id='ERP5UserManager_authenticateCredentials',
cache_factory='erp5_core_short')
return _authenticateCredentials( return _authenticateCredentials(
login=credentials.get('login'), login=credentials.get('login'),
password=credentials.get('password'), password=credentials.get('password'),
...@@ -152,7 +153,8 @@ class ERP5UserManager(BasePlugin): ...@@ -152,7 +153,8 @@ class ERP5UserManager(BasePlugin):
return tuple(user_info) return tuple(user_info)
_enumerateUsers = CachingMethod(_enumerateUsers, _enumerateUsers = CachingMethod(_enumerateUsers,
id='ERP5UserManager_enumerateUsers') id='ERP5UserManager_enumerateUsers',
cache_factory='erp5_core_short')
if id is None: if id is None:
id = login id = login
......
...@@ -104,7 +104,7 @@ def _evaluateTales(instance=None, value=None): ...@@ -104,7 +104,7 @@ def _evaluateTales(instance=None, value=None):
econtext = createExpressionContext(instance) econtext = createExpressionContext(instance)
return expression(econtext) return expression(econtext)
evaluateTales = CachingMethod(_evaluateTales, id = 'evaluateTales', cache_duration=300) evaluateTales = CachingMethod(_evaluateTales, id = 'evaluateTales', cache_factory='erp5_core_short')
class Getter(Method): class Getter(Method):
""" """
......
...@@ -967,6 +967,7 @@ class Base( CopyContainer, ...@@ -967,6 +967,7 @@ class Base( CopyContainer,
self._aq_dynamic('id') # Make sure _aq_dynamic has been called once self._aq_dynamic('id') # Make sure _aq_dynamic has been called once
if hasattr(Base.aq_portal_type[self.portal_type], accessor_name): if hasattr(Base.aq_portal_type[self.portal_type], accessor_name):
method = getattr(self, accessor_name) method = getattr(self, accessor_name)
LOG("Base.py", 0, "method = %s, name = %s" %(method, accessor_name))
method(value, **kw) method(value, **kw)
return return
if hasattr(Base.aq_portal_type[self.portal_type], public_accessor_name): if hasattr(Base.aq_portal_type[self.portal_type], public_accessor_name):
...@@ -2314,7 +2315,8 @@ class Base( CopyContainer, ...@@ -2314,7 +2315,8 @@ class Base( CopyContainer,
return getattr(ti, 'acquire_local_roles', True) return getattr(ti, 'acquire_local_roles', True)
cached_getAcquireLocalRoles = CachingMethod(cached_getAcquireLocalRoles, cached_getAcquireLocalRoles = CachingMethod(cached_getAcquireLocalRoles,
id='Base__getAcquireLocalRoles') id='Base__getAcquireLocalRoles',
cache_factory='erp5_core_short')
return cached_getAcquireLocalRoles(portal_type=self.getPortalType()) return cached_getAcquireLocalRoles(portal_type=self.getPortalType())
security.declareProtected(Permissions.View, 'get_local_permissions') security.declareProtected(Permissions.View, 'get_local_permissions')
...@@ -2588,7 +2590,8 @@ class Base( CopyContainer, ...@@ -2588,7 +2590,8 @@ class Base( CopyContainer,
cached_getQuantityPrecisionFromResource = CachingMethod( cached_getQuantityPrecisionFromResource = CachingMethod(
cached_getQuantityPrecisionFromResource, cached_getQuantityPrecisionFromResource,
id='Base_getQuantityPrecisionFromResource') id='Base_getQuantityPrecisionFromResource',
cache_factory='erp5_core_short')
return cached_getQuantityPrecisionFromResource(resource) return cached_getQuantityPrecisionFromResource(resource)
......
...@@ -33,7 +33,7 @@ from CachePlugins.BaseCache import CachedMethodError ...@@ -33,7 +33,7 @@ from CachePlugins.BaseCache import CachedMethodError
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
DEFAULT_CACHE_SCOPE = 'GLOBAL' DEFAULT_CACHE_SCOPE = 'GLOBAL'
DEFAULT_CACHE_FACTORY = 'erp5_user_interface' DEFAULT_CACHE_FACTORY = 'erp5_user_interface_short'
is_cache_initialized = 0 is_cache_initialized = 0
def initializePortalCachingProperties(self): def initializePortalCachingProperties(self):
......
...@@ -91,7 +91,7 @@ class PortalTypeClass(Constraint): ...@@ -91,7 +91,7 @@ class PortalTypeClass(Constraint):
_getClassForPortalTypeCache = CachingMethod( _getClassForPortalTypeCache = CachingMethod(
_getClassForPortalTypeCache, _getClassForPortalTypeCache,
"PortalTypeClass._getClassForPortalTypeCache", "PortalTypeClass._getClassForPortalTypeCache",
cache_duration = 60 * 10 cache_factory = 'erp5_core_medium'
) )
return _getClassForPortalTypeCache(obj.getPortalType()) return _getClassForPortalTypeCache(obj.getPortalType())
...@@ -689,7 +689,7 @@ class Folder( CopyContainer, CMFBTreeFolder, Base, FolderMixIn): ...@@ -689,7 +689,7 @@ class Folder( CopyContainer, CMFBTreeFolder, Base, FolderMixIn):
_getVisibleAllowedContentTypeList = CachingMethod( _getVisibleAllowedContentTypeList = CachingMethod(
_getVisibleAllowedContentTypeList, _getVisibleAllowedContentTypeList,
id=("_getAllowedContentTypeTitleList", user, portal_path, portal_type), id=("_getAllowedContentTypeTitleList", user, portal_path, portal_type),
cache_duration=None) cache_factory='erp5_core_long')
return _getVisibleAllowedContentTypeList() return _getVisibleAllowedContentTypeList()
security.declarePublic('allowedContentTypes') security.declarePublic('allowedContentTypes')
......
...@@ -1016,7 +1016,7 @@ class Catalog( Folder, ...@@ -1016,7 +1016,7 @@ class Catalog( Folder,
keys = keys.keys() keys = keys.keys()
keys.sort() keys.sort()
return keys return keys
return CachingMethod(_getColumnIds, id='SQLCatalog.getColumnIds', cache_duration=None)() return CachingMethod(_getColumnIds, id='SQLCatalog.getColumnIds', cache_factory='erp5_core_long')()
def getColumnMap(self): def getColumnMap(self):
""" """
...@@ -1035,7 +1035,7 @@ class Catalog( Folder, ...@@ -1035,7 +1035,7 @@ class Catalog( Folder,
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)() return CachingMethod(_getColumnMap, id='SQLCatalog.getColumnMap', cache_factory='erp5_core_long')()
def getResultColumnIds(self): def getResultColumnIds(self):
""" """
...@@ -1696,7 +1696,7 @@ class Catalog( Folder, ...@@ -1696,7 +1696,7 @@ class Catalog( Folder,
%(table_index, table)) %(table_index, table))
return table_index return table_index
return CachingMethod(_getTableIndex, id='SQLCatalog.getTableIndex', \ return CachingMethod(_getTableIndex, id='SQLCatalog.getTableIndex', \
cache_duration=None)(table=table) cache_factory='erp5_core_long')(table=table)
def getIndex(self, table, column_list): def getIndex(self, table, column_list):
...@@ -1731,7 +1731,7 @@ class Catalog( Folder, ...@@ -1731,7 +1731,7 @@ class Catalog( Folder,
LOG("SQLCatalog.getIndex", ERROR, "best_index = %s for table %s and columns %s" \ LOG("SQLCatalog.getIndex", ERROR, "best_index = %s for table %s and columns %s" \
%(best_index, table, column_list)) %(best_index, table, column_list))
return best_index return best_index
return CachingMethod(_getIndex, id='SQLCatalog.getIndex', cache_duration=None)\ return CachingMethod(_getIndex, id='SQLCatalog.getIndex', cache_factory='erp5_core_long')\
(table=table, column_list=column_list) (table=table, column_list=column_list)
def buildSQLQuery(self, query_table='catalog', REQUEST=None, def buildSQLQuery(self, query_table='catalog', REQUEST=None,
......
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