From 46908781ea4fe98f6bf089863042217b807c2098 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Sat, 28 Jan 2006 17:36:21 +0000
Subject: [PATCH] check that portal type is in workflow chain at install

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5411 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BusinessTemplate.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index 7ae94f383b..81f09039f7 100755
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -1094,15 +1094,18 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem):
         workflow = wflist[1]
       else:
         portal_type = wflist[0]
-        workflow = ''      
-      if workflow not in chain_dict['chain_%s' % portal_type]:
-        raise 
-      if self._objects.has_key(portal_type):
-        workflow_list = self._objects[portal_type]
-        workflow_list.append(workflow)
-        self._objects[portal_type] = workflow_list
+        workflow = ''
+      if chain_dict.has_key('chain_%s' % portal_type):
+        if workflow not in chain_dict['chain_%s' % portal_type]:
+          raise
+        if self._objects.has_key(portal_type):
+          workflow_list = self._objects[portal_type]
+          workflow_list.append(workflow)
+          self._objects[portal_type] = workflow_list
+        else:
+          self._objects[portal_type] = [workflow]
       else:
-        self._objects[portal_type] = [workflow]
+        LOG('BusinessTemplate build', 0, 'portal type %s not found in workflow chain' %(portal_type))
 
   def generateXml(self, path=None):
     xml_data = '<workflow_chain>'
@@ -4262,7 +4265,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
           base_category_list = portal_type.base_category_list       
         if hasattr(portal_type, 'listActions'):
           action_list = [x.getId() for x in portal_type.listActions()]
-        if chain_dict.has_key('chain_%s' % id):          
+        if chain_dict.has_key('chain_%s' % id):
           wf_list = chain_dict['chain_%s' % id].split(', ')
         
         for a_id in allowed_content_type_list:
-- 
2.30.9