Commit 04a1e6a3 authored by Arnaud Fontaine's avatar Arnaud Fontaine

When importing all the Property Sheets to ZODB, delete existing ones

and perform a commit after each import, then redirect to
portal_property_sheets.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39875 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3a6ee2da
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
# #
############################################################################## ##############################################################################
import transaction
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
...@@ -36,7 +38,7 @@ from Products.CMFCore.Expression import Expression ...@@ -36,7 +38,7 @@ from Products.CMFCore.Expression import Expression
from Products.ERP5Type.Base import Base, PropertyHolder from Products.ERP5Type.Base import Base, PropertyHolder
from Products.ERP5Type.Utils import setDefaultClassProperties, setDefaultProperties from Products.ERP5Type.Utils import setDefaultClassProperties, setDefaultProperties
from zLOG import LOG, ERROR, BLATHER from zLOG import LOG, ERROR, INFO
class PropertySheetTool(BaseTool): class PropertySheetTool(BaseTool):
""" """
...@@ -109,7 +111,7 @@ class PropertySheetTool(BaseTool): ...@@ -109,7 +111,7 @@ class PropertySheetTool(BaseTool):
security.declareProtected(Permissions.ManagePortal, security.declareProtected(Permissions.ManagePortal,
'createAllPropertySheetsFromFilesystem') 'createAllPropertySheetsFromFilesystem')
def createAllPropertySheetsFromFilesystem(self): def createAllPropertySheetsFromFilesystem(self, REQUEST=None):
""" """
Create Property Sheets in portal_property_sheets from _all_ Create Property Sheets in portal_property_sheets from _all_
filesystem Property Sheets filesystem Property Sheets
...@@ -123,15 +125,21 @@ class PropertySheetTool(BaseTool): ...@@ -123,15 +125,21 @@ class PropertySheetTool(BaseTool):
if name[0] == '_': if name[0] == '_':
continue continue
if name not in self.portal_property_sheets: if name in self.portal_property_sheets:
LOG("Tool.PropertySheetTool", BLATHER, self.portal_property_sheets.deleteContent(name)
"Creating %s in portal_property_sheets" % repr(name)) transaction.commit()
self.createPropertySheetFromFilesystemClass(klass) LOG("Tool.PropertySheetTool", INFO,
"Creating %s in portal_property_sheets" % repr(name))
else: self.createPropertySheetFromFilesystemClass(klass)
LOG("Tool.PropertySheetTool", BLATHER, transaction.commit()
"%s already exists in portal_property_sheets" % repr(name))
if REQUEST is not None:
return self.REQUEST.RESPONSE.redirect(
'%s/view?portal_status_message=' \
'Property Sheets successfully imported from filesystem to ZODB.' % \
self.absolute_url())
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'exportPropertySheetToFilesystemDefinitionTuple') 'exportPropertySheetToFilesystemDefinitionTuple')
......
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