From 6319ef54cfec6581b24c5515ca0762bf9b8cac91 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Fri, 22 Jan 2010 15:30:55 +0000
Subject: [PATCH] Display traceback when import fails, reviewed by Romain

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31918 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Utils.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py
index a26af2ec6d..d6a63bdf0e 100644
--- a/product/ERP5Type/Utils.py
+++ b/product/ERP5Type/Utils.py
@@ -33,6 +33,7 @@ import re
 import string
 import time
 import warnings
+import sys
 try:
   # Python 2.5 or later
   from hashlib import md5 as md5_new
@@ -71,6 +72,7 @@ from Products.ERP5Type.Accessor.Constant import Getter as ConstantGetter
 from Products.ERP5Type.Accessor.Interface import Getter as InterfaceGetter
 from Products.ERP5Type.Cache import getReadOnlyTransactionCache
 from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
+from zExceptions import ExceptionFormatter
 from zLOG import LOG, BLATHER, PROBLEM, WARNING
 
 #####################################################
@@ -1122,8 +1124,10 @@ def createConstraintList(property_holder, constraint_definition):
   try:
     consistency_class = getattr(Constraint, constraint_definition['type'])
   except AttributeError:
-    LOG("ERP5Type", PROBLEM, "Can not find Constraint: %s" % \
-                       constraint_definition['type'])
+    exc_info = sys.exc_info()
+    LOG("ERP5Type", PROBLEM, "Can not find Constraint: %s\n%s" % \
+                      (constraint_definition['type'],
+                      ''.join(ExceptionFormatter.format_exception(*exc_info))))
     raise ConstraintNotFound(repr(constraint_definition))
   consistency_instance = consistency_class(**constraint_definition)
   property_holder.constraints += [consistency_instance]
-- 
2.30.9