From 995cdc40485e19f0a2e78e920613268e733c0401 Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Sat, 9 Feb 2008 14:14:36 +0000
Subject: [PATCH] Make it easier to reconfigure the database connection of an
 existing site.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19203 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Security/ERP5GroupManager.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/product/ERP5Security/ERP5GroupManager.py b/product/ERP5Security/ERP5GroupManager.py
index 46827c071d..24262fd196 100644
--- a/product/ERP5Security/ERP5GroupManager.py
+++ b/product/ERP5Security/ERP5GroupManager.py
@@ -26,6 +26,7 @@ from Products.PluggableAuthService.interfaces.plugins import IGroupsPlugin
 from Products.ERP5Type.Cache import CachingMethod
 from Products.PluggableAuthService.PropertiedUser import PropertiedUser
 from ZODB.POSException import ConflictError
+from Shared.DC.ZRDB.DA import DatabaseError
 
 import sys
 
@@ -183,10 +184,23 @@ class ERP5GroupManager(BasePlugin):
                                              id='ERP5GroupManager_getGroupsForPrincipal',
                                              cache_factory='erp5_content_short')
 
-    return _getGroupsForPrincipal(
+    try:
+      return _getGroupsForPrincipal(
                 user_name=principal.getId(),
                 path=self.getPhysicalPath())
-
+    except ConflictError:
+      raise
+    except:
+      # Hiding this exception is necessary in order
+      # to be able to configure database connection
+      # on a existing site.
+      # Improved version may use ProgrammingError
+      # and DatabaseError exceptions explicitely
+      LOG('ERP5GroupManager', WARNING,
+          'could not call _getGroupsForPrincipal probably because of '
+          'misconfigured database connection',
+                  error = sys.exc_info())
+      return ()
 
 classImplements( ERP5GroupManager
                , IGroupsPlugin
-- 
2.30.9