Commit bdcd05da authored by Jérome Perrin's avatar Jérome Perrin

Temporary files are not always created in the same partition that instance...

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
parent 19066da6
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
# #
############################################################################## ##############################################################################
import os
import shutil
import tempfile
from Products.CMFCore.utils import UniqueObject from Products.CMFCore.utils import UniqueObject
from zExceptions import BadRequest from zExceptions import BadRequest
...@@ -35,7 +39,6 @@ from Globals import InitializeClass, DTMLFile ...@@ -35,7 +39,6 @@ from Globals import InitializeClass, DTMLFile
from App.config import getConfiguration from App.config import getConfiguration
from Products.ERP5Type.TM import VTM as TM from Products.ERP5Type.TM import VTM as TM
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
import os, tempfile
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type import _dtmldir from Products.ERP5Type import _dtmldir
...@@ -888,7 +891,7 @@ def initialize( context ): ...@@ -888,7 +891,7 @@ def initialize( context ):
os.remove(destination_file) os.remove(destination_file)
except OSError: except OSError:
pass pass
os.rename(source_file, destination_file) shutil.move(source_file, destination_file)
self.deleteTemporaryInstanceHome() self.deleteTemporaryInstanceHome()
security.declareProtected( Permissions.ManageExtensions, 'writeLocalPropertySheet' ) security.declareProtected( Permissions.ManageExtensions, 'writeLocalPropertySheet' )
......
...@@ -78,7 +78,11 @@ class %(property_sheet_name)s: ...@@ -78,7 +78,11 @@ class %(property_sheet_name)s:
class_tool = self.getClassTool() class_tool = self.getClassTool()
class_tool.newPropertySheet(property_sheet_name) 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) class_tool.editPropertySheet(property_sheet_name, property_sheet_code)
get_transaction().commit()
class_tool.importPropertySheet(property_sheet_name) class_tool.importPropertySheet(property_sheet_name)
# We set the property sheet on the portal type # We set the property sheet on the portal type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment