From bdcd05daca658c0c415cff4b5adf0d4ca51d6a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Thu, 15 Feb 2007 09:42:58 +0000 Subject: [PATCH] Temporary files are not always created in the same partition that instance home, so we cannot use os.rename. Update PropertySheetTestCase to commit transactions when creating and editing property sheets. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12713 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Tool/ClassTool.py | 7 +++++-- product/ERP5Type/tests/testERP5Type.py | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/product/ERP5Type/Tool/ClassTool.py b/product/ERP5Type/Tool/ClassTool.py index 0ac98101b0..1869b76066 100644 --- a/product/ERP5Type/Tool/ClassTool.py +++ b/product/ERP5Type/Tool/ClassTool.py @@ -26,6 +26,10 @@ # ############################################################################## +import os +import shutil +import tempfile + from Products.CMFCore.utils import UniqueObject from zExceptions import BadRequest @@ -35,7 +39,6 @@ from Globals import InitializeClass, DTMLFile from App.config import getConfiguration from Products.ERP5Type.TM import VTM as TM from Products.PageTemplates.PageTemplateFile import PageTemplateFile -import os, tempfile from Products.ERP5Type import Permissions from Products.ERP5Type import _dtmldir @@ -888,7 +891,7 @@ def initialize( context ): os.remove(destination_file) except OSError: pass - os.rename(source_file, destination_file) + shutil.move(source_file, destination_file) self.deleteTemporaryInstanceHome() security.declareProtected( Permissions.ManageExtensions, 'writeLocalPropertySheet' ) diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py index 45ce4609b9..21fee737b8 100644 --- a/product/ERP5Type/tests/testERP5Type.py +++ b/product/ERP5Type/tests/testERP5Type.py @@ -78,7 +78,11 @@ class %(property_sheet_name)s: class_tool = self.getClassTool() class_tool.newPropertySheet(property_sheet_name) + # XXX need to commit the transaction at this point, because class tool + # files are no longer available to the current transaction. + get_transaction().commit() class_tool.editPropertySheet(property_sheet_name, property_sheet_code) + get_transaction().commit() class_tool.importPropertySheet(property_sheet_name) # We set the property sheet on the portal type -- 2.30.9