Commit 890a8283 authored by Vincent Pelletier's avatar Vincent Pelletier

Use a request-scope variable to cache, instead of thread-scope.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5998 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent feed2e1f
...@@ -29,7 +29,7 @@ from AccessControl import ClassSecurityInfo ...@@ -29,7 +29,7 @@ from AccessControl import ClassSecurityInfo
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from Acquisition import aq_base from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface, Cache
from Products.ERP5.Document.Domain import Domain from Products.ERP5.Document.Domain import Domain
from Acquisition import ImplicitAcquisitionWrapper, aq_base, aq_inner from Acquisition import ImplicitAcquisitionWrapper, aq_base, aq_inner
from Products.ERP5Type.Base import TempBase from Products.ERP5Type.Base import TempBase
...@@ -83,30 +83,32 @@ class WebSite(Domain): ...@@ -83,30 +83,32 @@ class WebSite(Domain):
dynamic = Domain._aq_dynamic(self, name) dynamic = Domain._aq_dynamic(self, name)
if dynamic is not None : if dynamic is not None :
return dynamic return dynamic
# Do some optimisation here for names which can not the names of documents # Do some optimisation here for names which can not be names of documents
if name.startswith('_') or name.startswith('portal_')\ if name.startswith('_') or name.startswith('portal_')\
or name.startswith('aq_') or name.startswith('selection_') \ or name.startswith('aq_') or name.startswith('selection_') \
or name.startswith('sort-') or name == 'getLayout': or name.startswith('sort-') or name == 'getLayout':
return None return None
# Create a non recursion variable # Create a non recursion variable
if not hasattr(self, '_v_allow_lookup'): self._v_allow_lookup = {} allow_lookup = Cache.getTransactionCache(self)
if self._v_allow_lookup.has_key(name): if not allow_lookup:
return self._v_allow_lookup[name] Cache.enableTransactionCache(self)
allow_lookup = Cache.getTransactionCache(self)
elif allow_lookup.has_key(name):
return allow_lookup[name]
try: try:
self._v_allow_lookup[name] = None
old_manager = getSecurityManager()
portal = self.getPortalObject() portal = self.getPortalObject()
# Use the webmaster identity to find documents # Use the webmaster identity to find documents
user = portal.acl_users.getUserById(self.getWebmaster()) user = portal.acl_users.getUserById(self.getWebmaster())
if user is not None: if user is None:
newSecurityManager(get_request(), user) return None
document = self.WebSite_getDocument(portal, name) old_manager = getSecurityManager()
self._v_allow_lookup[name] = document newSecurityManager(get_request(), user)
setSecurityManager(old_manager) document = self.WebSite_getDocument(portal, name)
else: allow_lookup[name] = document
document = None setSecurityManager(old_manager)
except: except:
# Cleanup non recursion dict in case of exception # Cleanup non recursion dict in case of exception
if self._v_allow_lookup.has_key(name): del self._v_allow_lookup[name] if allow_lookup.has_key(name):
del allow_lookup[name]
raise raise
return document return document
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