from Globals import get_request
import time
from zLOG import LOG
CACHE_DURATION = 600
cached_template = {}
expires_date = {}
def getCachedPageTemplate(self, id=None, REQUEST=None):
global cached_template
global expires_date
if id is not None:
# Get the user id and request
if not REQUEST:
REQUEST = get_request()
user_id = self.portal_membership.getAuthenticatedMember().getUserName()
key = (user_id, id)
# lookup the cache for time
now = time.time()
# if cache exists and time is OK, return cache
expires = expires_date.get(key, now)
if expires > now:
LOG('CACHED:',0, str(id))
return cached_template[key]
# else recompute cache
method = getattr(self, id, None)
if method is not None:
cached_template[key] = method(REQUEST=REQUEST)
expires_date[key] = now + CACHE_DURATION
return cached_template[key]
else:
return ''
-
Yoshinori Okuji authored
Remove unneeded executable flags. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6280 20353a03-c40f-0410-a6d1-a30d3c3de9de
124efaba