Commit cf879a85 authored by Rafael Monnerat's avatar Rafael Monnerat

ERP5/Extensions: Remote unused extension

parent 25b79436
from Products.ERP5Type.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().getIdOrUserName()
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 ''
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