From ba6c616e7ed54a53735906e5fb2bd5177d467e3a Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Fri, 20 Jul 2007 14:29:05 +0000
Subject: [PATCH] Raise a more error message to help debugging. This should not
 impact the performance, as this method is cached.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15268 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/patches/CMFBTreeFolder.py | 25 +++++++++++-----------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/product/ERP5Type/patches/CMFBTreeFolder.py b/product/ERP5Type/patches/CMFBTreeFolder.py
index 24c82165cd..e64898707a 100644
--- a/product/ERP5Type/patches/CMFBTreeFolder.py
+++ b/product/ERP5Type/patches/CMFBTreeFolder.py
@@ -39,21 +39,22 @@ def CMFBTreeFolder_allowedContentTypes(self):
   if myType is not None:
     allowed_types_to_check = []
     if myType.filter_content_types:
-      result = [portal_types.getTypeInfo(x) for x in 
-                   myType.allowed_content_types]
+      for portal_type in myType.allowed_content_types:
+        contentType = portal_types.getTypeInfo(portal_type)
+        if contentType is None:
+          raise AttributeError, "Portal type '%s' does not exist " \
+                                "and should not be allowed in '%s'" % \
+                                (portal_type, self.getPortalType())
+        result.append(contentType)
     else:
-      if myType is not None:
-          for contentType in portal_types.listTypeInfo(self):
-              if myType.allowType( contentType.getId() ):
-                  result.append( contentType )
+      for contentType in portal_types.listTypeInfo(self):
+        if myType.allowType(contentType.getId()):
+          result.append(contentType)
   else:
       result = portal_types.listTypeInfo()
 
-  return filter( lambda typ, container=self:
-                    typ.isConstructionAllowed( container )
-               , result )
-
-
+  return filter(
+      lambda typ, container=self: typ.isConstructionAllowed(container),
+      result)
 
 CMFBTreeFolder.allowedContentTypes = CMFBTreeFolder_allowedContentTypes
-
-- 
2.30.9