Commit 94af0172 authored by Vincent Pelletier's avatar Vincent Pelletier

Add a cache on getUserByLogin because it's called from multiple method during...

Add a cache on getUserByLogin because it's called from multiple method during PAS internal execution flow.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15327 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f0af7bf8
...@@ -172,29 +172,37 @@ class ERP5UserManager(BasePlugin): ...@@ -172,29 +172,37 @@ class ERP5UserManager(BasePlugin):
# (no docstring to prevent publishing) # (no docstring to prevent publishing)
if not login: if not login:
return [] return []
# because we aren't logged in, we have to create our own
# SecurityManager to be able to access the Catalog
sm = getSecurityManager()
if sm.getUser().getId() != SUPER_USER:
newSecurityManager(self, self.getUser(SUPER_USER))
try: def _getUserByLogin(login):
import pdb; pdb.set_trace()
# because we aren't logged in, we have to create our own
# SecurityManager to be able to access the Catalog
sm = getSecurityManager()
if sm.getUser() != SUPER_USER:
newSecurityManager(self, self.getUser(SUPER_USER))
try: try:
result = self.getPortalObject().portal_catalog.unrestrictedSearchResults( try:
portal_type="Person", reference=login) result = self.getPortalObject().portal_catalog.unrestrictedSearchResults(
except ConflictError: portal_type="Person", reference=login)
raise except ConflictError:
except: raise
LOG('ERP5Security', PROBLEM, 'getUserByLogin failed', error=sys.exc_info()) except:
# Here we must raise an exception to prevent calers from caching LOG('ERP5Security', PROBLEM, 'getUserByLogin failed', error=sys.exc_info())
# a result of a degraded situation. # Here we must raise an exception to prevent calers from caching
# The kind of exception does not matter as long as it's catched by # a result of a degraded situation.
# PAS and causes a lookup using another plugin or user folder. # The kind of exception does not matter as long as it's catched by
# As PAS does not define explicitely such exception, we must use # PAS and causes a lookup using another plugin or user folder.
# the _SWALLOWABLE_PLUGIN_EXCEPTIONS list. # As PAS does not define explicitely such exception, we must use
raise _SWALLOWABLE_PLUGIN_EXCEPTIONS[0] # the _SWALLOWABLE_PLUGIN_EXCEPTIONS list.
finally: raise _SWALLOWABLE_PLUGIN_EXCEPTIONS[0]
setSecurityManager(sm) finally:
setSecurityManager(sm)
return result
_getUserByLogin = CachingMethod(_getUserByLogin,
id='ERP5UserManager_getUserByLogin',
cache_factory='erp5_content_short')
result = _getUserByLogin(login)
return [item.getObject() for item in result] return [item.getObject() for item in result]
classImplements( ERP5UserManager classImplements( ERP5UserManager
......
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