Commit 989644a4 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added constraint edition, cache reset, accessor reset


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2049 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 29a8bc7c
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002-2004 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com> # Jean-Paul Smets-Solanes <jp@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsability of assessing all potential
...@@ -39,312 +39,444 @@ from Products.ERP5Type.Document.Folder import Folder ...@@ -39,312 +39,444 @@ from Products.ERP5Type.Document.Folder import Folder
from Products.ERP5Type.Utils import readLocalPropertySheet, writeLocalPropertySheet, getLocalPropertySheetList from Products.ERP5Type.Utils import readLocalPropertySheet, writeLocalPropertySheet, getLocalPropertySheetList
from Products.ERP5Type.Utils import readLocalExtension, writeLocalExtension, getLocalExtensionList from Products.ERP5Type.Utils import readLocalExtension, writeLocalExtension, getLocalExtensionList
from Products.ERP5Type.Utils import readLocalDocument, writeLocalDocument, getLocalDocumentList from Products.ERP5Type.Utils import readLocalDocument, writeLocalDocument, getLocalDocumentList
from Products.ERP5Type.Utils import readLocalConstraint, writeLocalConstraint, getLocalConstraintList
from Products.ERP5Type.InitGenerator import getProductDocumentPathList from Products.ERP5Type.InitGenerator import getProductDocumentPathList
class ClassTool(BaseTool): from Products.ERP5Type.Base import _aq_reset
"""
A tool to edit code through the web
"""
id = 'portal_classes'
meta_type = 'ERP5 Class Tool'
# Declarative Security from Products.ERP5Type import allowClassTool
security = ClassSecurityInfo()
# if allowClassTool():
# ZMI methods
#
manage_options = ( ( { 'label' : 'Overview'
, 'action' : 'manage_overview'
}
,{ 'label' : 'Documents'
, 'action' : 'manage_viewDocumentList'
}
,{ 'label' : 'PropertySheets'
, 'action' : 'manage_viewPropertySheetList'
}
,{ 'label' : 'Extensions'
, 'action' : 'manage_viewExtensionList'
}
,
)
+ Folder.manage_options
)
security.declareProtected( Permissions.ManagePortal, 'manage_overview' ) class ClassTool(BaseTool):
manage_overview = DTMLFile( 'explainDocumentTool', _dtmldir )
security.declareProtected( Permissions.ManagePortal, 'manage_viewPropertySheetList' )
manage_viewPropertySheetList = DTMLFile( 'viewPropertySheetList', _dtmldir )
security.declareProtected( Permissions.ManagePortal, 'manage_viewDocumentList' )
manage_viewDocumentList = DTMLFile( 'viewDocumentList', _dtmldir )
security.declareProtected( Permissions.ManagePortal, 'manage_viewExtensionList' )
manage_viewExtensionList = DTMLFile( 'viewExtensionList', _dtmldir )
security.declareProtected( Permissions.ManagePortal, 'manage_editDocumentForm' )
manage_editDocumentForm = DTMLFile( 'editDocumentForm', _dtmldir )
security.declareProtected( Permissions.ManagePortal, 'manage_editExtensionForm' )
manage_editExtensionForm = DTMLFile( 'editExtensionForm', _dtmldir )
security.declareProtected( Permissions.ManagePortal, 'manage_editPropertySheetForm' )
manage_editPropertySheetForm = DTMLFile( 'editPropertySheetForm', _dtmldir )
security.declareProtected( Permissions.ManagePortal, 'getLocalPropertySheetList' )
def getLocalPropertySheetList(self):
"""
Return a list of PropertySheet id which can be modified through the web
"""
return getLocalPropertySheetList()
security.declareProtected( Permissions.ManagePortal, 'getLocalExtensionList' )
def getLocalExtensionList(self):
"""
Return a list of Extension id which can be modified through the web
""" """
return getLocalExtensionList() A tool to edit code through the web
security.declareProtected( Permissions.ManagePortal, 'getLocalDocumentList' )
def getLocalDocumentList(self):
""" """
Return a list of Document id which can be modified through the web id = 'portal_classes'
""" meta_type = 'ERP5 Class Tool'
return getLocalDocumentList()
security.declareProtected( Permissions.ManagePortal, 'getProductDocumentPathList' )
def getProductDocumentPathList(self):
"""
Return a list of Document id which can be modified through the web
"""
return getProductDocumentPathList()
security.declareProtected( Permissions.ManagePortal, 'getDocumentText' )
def getDocumentText(self, class_id):
"""
Updates a Document with a new text
"""
return readLocalDocument(class_id)
security.declareProtected( Permissions.ManageExtensions, 'newDocument' )
def newDocument(self, class_id, REQUEST=None):
"""
Updates a Document with a new text
"""
text = """
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.WorkflowCore import WorkflowMethod
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.XMLObject import XMLObject
class %s(XMLObject):
# CMF Type Definition
meta_type = 'MYPROJECT Template Document'
portal_type = 'Template Document'
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.View)
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
)""" % class_id
writeLocalDocument(class_id, text)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Created' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManageExtensions, 'editDocument' )
def editDocument(self, class_id, text, REQUEST=None):
"""
Updates a Document with a new text
"""
previous_text = readLocalDocument(class_id)
writeLocalDocument(class_id, text)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Saved' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManageExtensions, 'importDocument' )
def importDocument(self, class_id, class_path=None, REQUEST=None):
"""
Imports a document class
"""
from Products.ERP5Type.Utils import importLocalDocument
local_product = self.Control_Panel.Products.ERP5Type
app = local_product._p_jar.root()['Application']
importLocalDocument(class_id, document_path=class_path)
if REQUEST is not None and class_path is None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Reloaded+Successfully' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManagePortal, 'getPropertySheetText' )
def getPropertySheetText(self, class_id):
"""
Updates a PropertySheet with a new text
"""
return readLocalPropertySheet(class_id)
security.declareProtected( Permissions.ManageExtensions, 'newPropertySheet' )
def newPropertySheet(self, class_id, REQUEST=None):
"""
Updates a PropertySheet with a new text
"""
text = """
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class PropertySheetTemplate:
\"\"\"
PropertySheetTemplate properties for all ERP5 objects
\"\"\"
_properties = (
{ 'id' : 'a_property',
'description' : 'A local property description',
'type' : 'string',
'mode' : '' },
)
# Declarative Security
""" security = ClassSecurityInfo()
writeLocalPropertySheet(class_id, text)
if REQUEST is not None: #
REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&message=PropertySheet+Created' % (self.absolute_url(), class_id)) # ZMI methods
#
security.declareProtected( Permissions.ManageExtensions, 'editPropertySheet' ) manage_options = ( ( { 'label' : 'Overview'
def editPropertySheet(self, class_id, text, REQUEST=None): , 'action' : 'manage_overview'
""" }
Updates a PropertySheet with a new text ,{ 'label' : 'Documents'
""" , 'action' : 'manage_viewDocumentList'
previous_text = readLocalPropertySheet(class_id) }
writeLocalPropertySheet(class_id, text) ,{ 'label' : 'PropertySheets'
if REQUEST is not None: , 'action' : 'manage_viewPropertySheetList'
REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&message=PropertySheet+Saved' % (self.absolute_url(), class_id)) }
,{ 'label' : 'Constraints'
security.declareProtected( Permissions.ManageExtensions, 'importPropertySheet' ) , 'action' : 'manage_viewConstraintList'
def importPropertySheet(self, class_id, REQUEST=None): }
""" ,{ 'label' : 'Extensions'
Imports a PropertySheet class , 'action' : 'manage_viewExtensionList'
""" }
from Products.ERP5Type.Utils import importLocalPropertySheet ,
local_product = self.Control_Panel.Products.ERP5Type )
app = local_product._p_jar.root()['Application'] + tuple (
importLocalPropertySheet(class_id) filter(lambda a: a['label'] not in ('Contents', 'View'),
if REQUEST is not None: Folder.manage_options))
REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&message=PropertySheet+Reloaded+Successfully' % (self.absolute_url(), class_id)) )
security.declareProtected( Permissions.ManagePortal, 'getExtensionText' ) security.declareProtected( Permissions.ManagePortal, 'manage_overview' )
def getExtensionText(self, class_id): manage_overview = DTMLFile( 'explainDocumentTool', _dtmldir )
"""
Updates a Extension with a new text security.declareProtected( Permissions.ManagePortal, 'manage_viewPropertySheetList' )
""" manage_viewPropertySheetList = DTMLFile( 'viewPropertySheetList', _dtmldir )
return readLocalExtension(class_id)
security.declareProtected( Permissions.ManagePortal, 'manage_viewDocumentList' )
security.declareProtected( Permissions.ManageExtensions, 'newExtension' ) manage_viewDocumentList = DTMLFile( 'viewDocumentList', _dtmldir )
def newExtension(self, class_id, REQUEST=None):
""" security.declareProtected( Permissions.ManagePortal, 'manage_viewExtensionList' )
Updates a Extension with a new text manage_viewExtensionList = DTMLFile( 'viewExtensionList', _dtmldir )
"""
text = """ security.declareProtected( Permissions.ManagePortal, 'manage_viewConstraintList' )
############################################################################## manage_viewConstraintList = DTMLFile( 'viewConstraintList', _dtmldir )
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. security.declareProtected( Permissions.ManagePortal, 'manage_editDocumentForm' )
# manage_editDocumentForm = DTMLFile( 'editDocumentForm', _dtmldir )
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential security.declareProtected( Permissions.ManagePortal, 'manage_editExtensionForm' )
# consequences resulting from its eventual inadequacies and bugs manage_editExtensionForm = DTMLFile( 'editExtensionForm', _dtmldir )
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software security.declareProtected( Permissions.ManagePortal, 'manage_editConstraintForm' )
# Service Company manage_editConstraintForm = DTMLFile( 'editConstraintForm', _dtmldir )
#
# This program is Free Software; you can redistribute it and/or security.declareProtected( Permissions.ManagePortal, 'manage_editPropertySheetForm' )
# modify it under the terms of the GNU General Public License manage_editPropertySheetForm = DTMLFile( 'editPropertySheetForm', _dtmldir )
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # Clears the cache of all databases
# def _clearCache(self):
# This program is distributed in the hope that it will be useful, database = self.Control_Panel.Database
# but WITHOUT ANY WARRANTY; without even the implied warranty of for name in database.getDatabaseNames():
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the from zLOG import LOG
# GNU General Public License for more details. LOG('_clearCache', 0, str(name))
# database[name].manage_minimize()
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software security.declareProtected( Permissions.ManagePortal, 'getLocalPropertySheetList' )
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. def getLocalPropertySheetList(self):
# """
############################################################################## Return a list of PropertySheet id which can be modified through the web
"""
def myExtensionMethod(context, param=None): return getLocalPropertySheetList()
pass
""" security.declareProtected( Permissions.ManagePortal, 'getLocalExtensionList' )
writeLocalExtension(class_id, text) def getLocalExtensionList(self):
if REQUEST is not None: """
REQUEST.RESPONSE.redirect('%s/manage_editExtensionForm?class_id=%s&message=Extension+Created' % (self.absolute_url(), class_id)) Return a list of Extension id which can be modified through the web
"""
security.declareProtected( Permissions.ManageExtensions, 'editExtension' ) return getLocalExtensionList()
def editExtension(self, class_id, text, REQUEST=None):
security.declareProtected( Permissions.ManagePortal, 'getLocalConstraintList' )
def getLocalConstraintList(self):
"""
Return a list of Constraint id which can be modified through the web
"""
return getLocalConstraintList()
security.declareProtected( Permissions.ManagePortal, 'getLocalDocumentList' )
def getLocalDocumentList(self):
"""
Return a list of Document id which can be modified through the web
"""
return getLocalDocumentList()
security.declareProtected( Permissions.ManagePortal, 'getProductDocumentPathList' )
def getProductDocumentPathList(self):
"""
Return a list of Document id which can be modified through the web
"""
return getProductDocumentPathList()
security.declareProtected( Permissions.ManagePortal, 'getDocumentText' )
def getDocumentText(self, class_id):
"""
Updates a Document with a new text
"""
return readLocalDocument(class_id)
security.declareProtected( Permissions.ManageExtensions, 'newDocument' )
def newDocument(self, class_id, REQUEST=None):
"""
Updates a Document with a new text
"""
text = """
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.WorkflowCore import WorkflowMethod
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.XMLObject import XMLObject
class %s(XMLObject):
# CMF Type Definition
meta_type = 'MYPROJECT Template Document'
portal_type = 'Template Document'
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.View)
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
)""" % class_id
writeLocalDocument(class_id, text)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Created' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManageExtensions, 'editDocument' )
def editDocument(self, class_id, text, REQUEST=None):
"""
Updates a Document with a new text
"""
previous_text = readLocalDocument(class_id)
writeLocalDocument(class_id, text, create=0)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Saved' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManageExtensions, 'importDocument' )
def importDocument(self, class_id, class_path=None, REQUEST=None):
"""
Imports a document class
"""
from Products.ERP5Type.Utils import importLocalDocument
local_product = self.Control_Panel.Products.ERP5Type
app = local_product._p_jar.root()['Application']
importLocalDocument(class_id, document_path=class_path)
# Clear object cache and reset _aq_dynamic after reload
self._clearCache()
_aq_reset()
if REQUEST is not None and class_path is None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Reloaded+Successfully' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManagePortal, 'getPropertySheetText' )
def getPropertySheetText(self, class_id):
"""
Updates a PropertySheet with a new text
"""
return readLocalPropertySheet(class_id)
security.declareProtected( Permissions.ManageExtensions, 'newPropertySheet' )
def newPropertySheet(self, class_id, REQUEST=None):
"""
Updates a PropertySheet with a new text
"""
text = """
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class PropertySheetTemplate:
\"\"\"
PropertySheetTemplate properties for all ERP5 objects
\"\"\"
_properties = (
{ 'id' : 'a_property',
'description' : 'A local property description',
'type' : 'string',
'mode' : '' },
)
"""
writeLocalPropertySheet(class_id, text)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&message=PropertySheet+Created' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManageExtensions, 'editPropertySheet' )
def editPropertySheet(self, class_id, text, REQUEST=None):
"""
Updates a PropertySheet with a new text
"""
previous_text = readLocalPropertySheet(class_id)
writeLocalPropertySheet(class_id, text, create=0)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&message=PropertySheet+Saved' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManageExtensions, 'importPropertySheet' )
def importPropertySheet(self, class_id, REQUEST=None):
"""
Imports a PropertySheet class
"""
from Products.ERP5Type.Utils import importLocalPropertySheet
local_product = self.Control_Panel.Products.ERP5Type
app = local_product._p_jar.root()['Application']
importLocalPropertySheet(class_id)
# Reset _aq_dynamic after reload
# There is no need to reset the cache in this case because
# XXX it is not sure however that class defined propertysheets will be updated
_aq_reset()
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&message=PropertySheet+Reloaded+Successfully' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManagePortal, 'getExtensionText' )
def getExtensionText(self, class_id):
"""
Updates a Extension with a new text
"""
return readLocalExtension(class_id)
security.declareProtected( Permissions.ManageExtensions, 'newExtension' )
def newExtension(self, class_id, REQUEST=None):
"""
Updates a Extension with a new text
"""
text = """
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
def myExtensionMethod(self, param=None):
pass
"""
writeLocalExtension(class_id, text)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editExtensionForm?class_id=%s&message=Extension+Created' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManageExtensions, 'editExtension' )
def editExtension(self, class_id, text, REQUEST=None):
"""
Updates a Extension with a new text
"""
previous_text = readLocalExtension(class_id)
writeLocalExtension(class_id, text, create=0)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editExtensionForm?class_id=%s&message=Extension+Saved' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManagePortal, 'getConstraintText' )
def getConstraintText(self, class_id):
"""
Updates a Constraint with a new text
"""
return readLocalConstraint(class_id)
security.declareProtected( Permissions.ManageExtensions, 'newConstraint' )
def newConstraint(self, class_id, REQUEST=None):
"""
Updates a Constraint with a new text
"""
text = """
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Products.ERP5Type.Constraint import Constraint
class ConstraintTemplate(Constraint):
\"\"\"
Explain here what this constraint checker does
\"\"\"
def checkConsistency(self, object, fixit = 0):
\"\"\"
Implement here the consistency checker
whenever fixit is not 0, object data should be updated to
satisfy the constraint
\"\"\"
errors = []
# Do the job here
return errors
"""
writeLocalConstraint(class_id, text)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editConstraintForm?class_id=%s&message=Constraint+Created' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManageExtensions, 'editConstraint' )
def editConstraint(self, class_id, text, REQUEST=None):
"""
Updates a Constraint with a new text
"""
previous_text = readLocalConstraint(class_id)
writeLocalConstraint(class_id, text, create=0)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editConstraintForm?class_id=%s&message=Constraint+Saved' % (self.absolute_url(), class_id))
else:
class ClassTool(BaseTool):
""" """
Updates a Extension with a new text A tool to edit code through the web
""" """
previous_text = readLocalExtension(class_id) id = 'portal_classes'
writeLocalExtension(class_id, text) meta_type = 'ERP5 Dummy Class Tool'
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editExtensionForm?class_id=%s&message=Extension+Saved' % (self.absolute_url(), class_id)) # Declarative Security
security = ClassSecurityInfo()
security.declareProtected( Permissions.ManagePortal, 'manage_overview' )
manage_overview = DTMLFile( 'explainDummyClassTool', _dtmldir )
InitializeClass(ClassTool) InitializeClass(ClassTool)
\ No newline at end of file
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