From 810490e2d4f0978f682d09de48286a6147753c61 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Fri, 21 Nov 2008 15:24:07 +0000
Subject: [PATCH] Try to create parent directories for PropertySheet and
 Constraints if not already present.

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

diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py
index c7c62ba235..ed64557782 100644
--- a/product/ERP5Type/Utils.py
+++ b/product/ERP5Type/Utils.py
@@ -51,7 +51,7 @@ from Products.ERP5Type import Permissions
 from Products.ERP5Type import Constraint
 
 from Products.ERP5Type.Cache import getReadOnlyTransactionCache
-from zLOG import LOG, BLATHER, PROBLEM
+from zLOG import LOG, BLATHER, PROBLEM, WARNING
 
 
 #####################################################
@@ -457,6 +457,9 @@ def writeLocalPropertySheet(class_id, text, create=1, instance_home=None):
   if instance_home is None:
     instance_home = getConfiguration().instancehome
   path = os.path.join(instance_home, "PropertySheet")
+  if not os.path.exists(path):
+    os.mkdir(path)
+    LOG('ERP5Type', WARNING, 'Created missing but required directory: %s' %path)  
   path = os.path.join(path, "%s.py" % class_id)
   if create:
     if os.path.exists(path):
@@ -638,6 +641,9 @@ def writeLocalConstraint(class_id, text, create=1, instance_home=None):
   if instance_home is None:
     instance_home = getConfiguration().instancehome
   path = os.path.join(instance_home, "Constraint")
+  if not os.path.exists(path):
+    os.mkdir(path)
+    LOG('ERP5Type', WARNING, 'Created missing but required directory: %s' %path)
   path = os.path.join(path, "%s.py" % class_id)
   if create:
     if os.path.exists(path):
-- 
2.30.9