From ad0be1ffabf6d1c4d764c7ab8f547ac468d91264 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Thu, 27 Oct 2005 09:36:40 +0000
Subject: [PATCH] raise exception if business template is not 'built' for
 exporting remove unused exported property of business template

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4142 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BusinessTemplate.py | 9 +++++++--
 product/ERP5/Tool/TemplateTool.py         | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index 208bc0ac13..f6e334d0e9 100755
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -224,6 +224,8 @@ class BusinessTemplateTarball(BusinessTemplateArchive):
     tar.close()
     io.close()
 
+class TemplateConditionError(Exception): pass
+
 class TemplateConflictError(Exception): pass
 
 class BaseTemplateItem(Implicit, Persistent):
@@ -2369,6 +2371,10 @@ Business Template is a set of definitions, such as skins, portal types and categ
       """
         Export this Business Template
       """
+      if self.getBuildingState() != 'built':
+        raise TemplateConditionError, 'Business Template must be build before export'
+
+      
       if local:
         # we export into a folder tree
         bta = BusinessTemplateFolder(creation=1, path=path)
@@ -2381,8 +2387,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
       for prop in self.propertyMap():
         type = prop['type']
         id = prop['id']
-#        if id in ('uid', 'rid', 'sid', 'id_group', 'last_id'):
-        if id in ('uid'): # maybe remove rid, sid
+        if id in ('uid', 'rid', 'sid', 'id_group', 'last_id'):
           continue        
         value = self.getProperty(id)
         if type == 'text' or type == 'string' or type == 'int':
diff --git a/product/ERP5/Tool/TemplateTool.py b/product/ERP5/Tool/TemplateTool.py
index 51679c66fe..680db7ab0d 100755
--- a/product/ERP5/Tool/TemplateTool.py
+++ b/product/ERP5/Tool/TemplateTool.py
@@ -190,7 +190,7 @@ class TemplateTool (BaseTool):
         for prop in bt.propertyMap():
           type = prop['type']
           pid = prop['id']
-          if pid in ('uid', 'id'):
+          if pid in ('uid', 'id', 'rid', 'sid', 'id_group', 'last_id'):
             continue
           prop_path = os.path.join(tar.members[0].name, 'bt', pid)
           info = tar.getmember(prop_path)
@@ -234,7 +234,7 @@ class TemplateTool (BaseTool):
         for prop in bt.propertyMap():
           type = prop['type']
           pid = prop['id']
-          if pid in ('uid', 'id'):
+          if pid in ('uid', 'id', 'rid', 'sid', 'id_group', 'last_id'):
             continue
           prop_path = os.path.join(bt_path, pid)
           value = open(prop_path, 'r').read()
-- 
2.30.9