--- a/src/pyams_security/utility.py Wed Jun 26 11:14:21 2019 +0200
+++ b/src/pyams_security/utility.py Thu Jul 02 09:09:57 2020 +0200
@@ -15,6 +15,7 @@
import logging
from functools import lru_cache
+from ZODB.POSException import ConnectionStateError
from beaker.cache import cache_region
from pyramid.authentication import AuthTktCookieHelper
from pyramid.decorator import reify
@@ -25,8 +26,9 @@
from zope.interface import implementer
from zope.schema.fieldproperty import FieldProperty
-from pyams_security.interfaces import AuthenticatedPrincipalEvent, IAuthenticationPlugin, ICredentialsPlugin, \
- IDirectoryPlugin, IGroupsAwareDirectoryPlugin, IProtectedObject, ISecurityManager
+from pyams_security.interfaces import AuthenticatedPrincipalEvent, IAuthenticationPlugin, \
+ ICredentialsPlugin, IDirectoryPlugin, IGroupsAwareDirectoryPlugin, IProtectedObject, \
+ ISecurityManager
from pyams_security.principal import MissingPrincipal, UnknownPrincipal
from pyams_utils.registry import query_utility
from pyams_utils.request import check_request, request_property
@@ -265,7 +267,11 @@
return principal_id
manager = self._get_security_manager(request)
if manager is not None:
- return manager.authenticated_userid(request)
+ try:
+ return manager.authenticated_userid(request)
+ except ConnectionStateError:
+ pass
+ return None
@request_property(key=None)
def effective_principals(self, request, context=None):