Commit 7e47f580 authored by Sebastien Robin's avatar Sebastien Robin

create new ERP5 class PythonScript. Add a constructor specific

for the ZMI, this specific constructor can be safely removed
later.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37965 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f3154e76
##############################################################################
#
# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
#
# 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.ERP5Type import Permissions, PropertySheet
from App.special_dtml import HTMLFile
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.Ticket import Ticket
from Products.PythonScripts.PythonScript import \
PythonScript as ZopePythonScript
# Only needed until skin tool is migrated
manage_addPythonScriptFormThroughZMI = \
HTMLFile("../dtml/addPythonScriptThroughZMI", globals())
def addPythonScriptThroughZMI(self, id, title="", REQUEST=None):
"""Add a Python script to a folder.
"""
from Products.ERP5Type.Document import addPythonScript
type_info = self.getPortalObject().portal_types.getTypeInfo("Python Script")
type_info.constructInstance(
container=self,
id=id)
if REQUEST is not None:
try: u = self.DestinationURL()
except: u = REQUEST['URL1']
REQUEST.RESPONSE.redirect(u+'/manage_main')
class PythonScriptThroughZMI(XMLObject):
"""
Dummy class only used to do construction through zmi of PythonScript
This class needs to be removed as soon as portal_skins is an ERP5 object
"""
meta_type = 'ERP5 Python Script Through ZMI'
portal_type = 'Python Script Through ZMI'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
constructors = (manage_addPythonScriptFormThroughZMI,
addPythonScriptThroughZMI)
icon = None
class PythonScript(XMLObject, ZopePythonScript):
""" Script python for ERP5
"""
meta_type = 'ERP5 Python Script'
portal_type = 'Python Script'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
)
def _setBody(self, value):
"""
override to call ZopePythonScript methods to initialize code
"""
self.write(value)
__call__ = ZopePythonScript.__call__
def edit(self, **kw):
XMLObject.edit(self, **kw)
##############################################################################
#
# Copyright (c) 2002-2010 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility 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
# guarantees 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
class PythonScript:
"""
PythonScript properties for all ERP5 objects
"""
_properties = (
{ 'id' : 'body',
'description' : 'A local property description',
'type' : 'string',
'storage_id' : '_body',
'mode' : '' },
{ 'id' : 'parameter_signature',
'description' : 'A local property description',
'type' : 'string',
'storage_id' : '_params',
'mode' : '' },
)
...@@ -42,4 +42,9 @@ class SubversionPreference: ...@@ -42,4 +42,9 @@ class SubversionPreference:
'type' : 'lines', 'type' : 'lines',
'preference' : 1, 'preference' : 1,
'mode' : 'w' }, 'mode' : 'w' },
{ 'id' : 'preferred_diff_filter_script_id',
'description' : 'Scripts to filter what is displayed in diffs ',
'type' : 'lines',
'preference' : 1,
'mode' : 'w' },
) )
...@@ -626,9 +626,13 @@ class TemplateTool (BaseTool): ...@@ -626,9 +626,13 @@ class TemplateTool (BaseTool):
""" """
Return list of scripts usable to filter diff Return list of scripts usable to filter diff
""" """
# XXX-Aurel : this will be removed in a near future when script # XXX, the or [] should not be there, the preference tool is
# will be configurable on the tool # inconsistent, the called method should not return None when
return [getattr(self, 'TemplateTool_filterTupleDiff'),] # nothing is selected
script_id_list = self.getPortalObject().portal_preferences\
.getPreferredDiffFilterScriptIdList() or []
return [getattr(self, x) for x in script_id_list]
def getFilteredDiffAsHTML(self, diff): def getFilteredDiffAsHTML(self, diff):
""" """
......
...@@ -52,7 +52,9 @@ from Tool import CategoryTool, SimulationTool, RuleTool, IdTool, TemplateTool,\ ...@@ -52,7 +52,9 @@ from Tool import CategoryTool, SimulationTool, RuleTool, IdTool, TemplateTool,\
AcknowledgementTool, SolverTool, SolverProcessTool,\ AcknowledgementTool, SolverTool, SolverProcessTool,\
ConversionTool, RoundingTool ConversionTool, RoundingTool
import ERP5Site import ERP5Site
from Document import PythonScript
object_classes = ( ERP5Site.ERP5Site, object_classes = ( ERP5Site.ERP5Site,
PythonScript.PythonScriptThroughZMI,
) )
portal_tools = ( CategoryTool.CategoryTool, portal_tools = ( CategoryTool.CategoryTool,
SimulationTool.SimulationTool, SimulationTool.SimulationTool,
......
<dtml-var manage_page_header>
<dtml-var "manage_form_title(this(), _,
form_title='Add ERP5 Formulator Form',
)">
<p class="form-help">
Formulator Forms allow you to create solid web forms more easily.
</p>
<form action="addPythonScriptThroughZMI" method="POST">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
Id
</div>
</td>
<td align="left" valign="top">
<input type="text" name="id" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Title
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="submit"
value=" Add " />
<input class="form-element" type="submit" name="submit"
value=" Add and Edit " />
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
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