From 711265eab9e4782d6af815ca9090f6f86ffcd50c Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Thu, 4 Jan 2007 09:49:38 +0000
Subject: [PATCH] Add a missing import. Add an explicit raise.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11894 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Security/ERP5UserManager.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/product/ERP5Security/ERP5UserManager.py b/product/ERP5Security/ERP5UserManager.py
index 106a3784d9..16c8157492 100644
--- a/product/ERP5Security/ERP5UserManager.py
+++ b/product/ERP5Security/ERP5UserManager.py
@@ -20,12 +20,14 @@ from AccessControl import ClassSecurityInfo
 from AccessControl.SecurityManagement import getSecurityManager,\
     setSecurityManager, newSecurityManager
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from Products.PluggableAuthService.PluggableAuthService import _SWALLOWABLE_PLUGIN_EXCEPTIONS
 from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin
 from Products.PluggableAuthService.utils import classImplements
 from Products.PluggableAuthService.interfaces.plugins import IAuthenticationPlugin
 from Products.PluggableAuthService.interfaces.plugins import IUserEnumerationPlugin
 from Products.ERP5Type.Cache import CachingMethod
 from ZODB.POSException import ConflictError
+import sys
 
 from zLOG import LOG
 
@@ -182,6 +184,13 @@ class ERP5UserManager(BasePlugin):
             raise
           except:
             LOG('ERP5Security', 0, 'getUserByLogin failed', error=sys.exc_info())
+            # Here we must raise an exception to prevent calers from caching
+            # a result of a degraded situation.
+            # The kind of exception does not matter as long as it's catched by
+            # PAS and causes a lookup using another plugin or user folder.
+            # As PAS does not define explicitely such exception, we must use
+            # the _SWALLOWABLE_PLUGIN_EXCEPTIONS list.
+            raise _SWALLOWABLE_PLUGIN_EXCEPTIONS[0]
         finally:
           setSecurityManager(sm)
         return [item.getObject() for item in result]
-- 
2.30.9