[Erp5-report] r37965 seb - in /erp5/trunk/products/ERP5: ./ Document/ PropertySheet/ Tool/ ...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Aug 24 09:44:56 CEST 2010


Author: seb
Date: Tue Aug 24 09:44:53 2010
New Revision: 37965

URL: http://svn.erp5.org?rev=37965&view=rev
Log:
create new ERP5 class PythonScript. Add a constructor specific
for the ZMI, this specific constructor can be safely removed
later.

Added:
    erp5/trunk/products/ERP5/Document/PythonScript.py
    erp5/trunk/products/ERP5/PropertySheet/PythonScript.py
      - copied, changed from r37964, erp5/trunk/products/ERP5/PropertySheet/SubversionPreference.py
    erp5/trunk/products/ERP5/dtml/addPythonScriptThroughZMI.dtml
Modified:
    erp5/trunk/products/ERP5/PropertySheet/SubversionPreference.py
    erp5/trunk/products/ERP5/Tool/TemplateTool.py
    erp5/trunk/products/ERP5/__init__.py

Added: erp5/trunk/products/ERP5/Document/PythonScript.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PythonScript.py?rev=37965&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/Document/PythonScript.py (added)
+++ erp5/trunk/products/ERP5/Document/PythonScript.py [utf8] Tue Aug 24 09:44:53 2010
@@ -0,0 +1,100 @@
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Sebastien Robin <seb at 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)

Copied: erp5/trunk/products/ERP5/PropertySheet/PythonScript.py (from r37964, erp5/trunk/products/ERP5/PropertySheet/SubversionPreference.py)
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/PropertySheet/PythonScript.py?p2=erp5/trunk/products/ERP5/PropertySheet/PythonScript.py&p1=erp5/trunk/products/ERP5/PropertySheet/SubversionPreference.py&r1=37964&r2=37965&rev=37965&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/PropertySheet/SubversionPreference.py [utf8] (original)
+++ erp5/trunk/products/ERP5/PropertySheet/PythonScript.py [utf8] Tue Aug 24 09:44:53 2010
@@ -1,13 +1,12 @@
 ##############################################################################
 #
-# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
-#                    Yoshinori Okuji <yo at nexedi.com>
+# 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 responsability of assessing all potential
+# 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
-# garantees and support are strongly adviced to contract a Free Software
+# guarantees and support are strongly adviced to contract a Free Software
 # Service Company
 #
 # This program is Free Software; you can redistribute it and/or
@@ -22,24 +21,26 @@
 #
 # 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.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 ##############################################################################
 
-class SubversionPreference:
+class PythonScript:
   """
-    User Preferences for Subversion
+      PythonScript properties for all ERP5 objects
   """
-  
+
   _properties = (
-    { 'id'          : 'preferred_subversion_user_name',
-      'description' : 'The user name for Subversion',
-      'type'        : 'string',
-      'preference'  : 1,
-      'mode'        : 'w' },
-    { 'id'          : 'preferred_subversion_working_copy',
-      'description' : 'The Subversion working copies',
-      'type'        : 'lines',
-      'preference'  : 1,
-      'mode'        : 'w' },
+      {   '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'        : '' },
   )
+
+

Modified: erp5/trunk/products/ERP5/PropertySheet/SubversionPreference.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/PropertySheet/SubversionPreference.py?rev=37965&r1=37964&r2=37965&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/PropertySheet/SubversionPreference.py [utf8] (original)
+++ erp5/trunk/products/ERP5/PropertySheet/SubversionPreference.py [utf8] Tue Aug 24 09:44:53 2010
@@ -42,4 +42,9 @@ class SubversionPreference:
       'type'        : 'lines',
       'preference'  : 1,
       'mode'        : 'w' },
+    { 'id'          : 'preferred_diff_filter_script_id',
+      'description' : 'Scripts to filter what is displayed in diffs ',
+      'type'        : 'lines',
+      'preference'  : 1,
+      'mode'        : 'w' },
   )

Modified: erp5/trunk/products/ERP5/Tool/TemplateTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/TemplateTool.py?rev=37965&r1=37964&r2=37965&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/TemplateTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/TemplateTool.py [utf8] Tue Aug 24 09:44:53 2010
@@ -626,9 +626,13 @@ class TemplateTool (BaseTool):
       """
       Return list of scripts usable to filter diff
       """
-      # XXX-Aurel : this will be removed in a near future when script
-      # will be configurable on the tool
-      return [getattr(self, 'TemplateTool_filterTupleDiff'),]
+      # XXX, the or [] should not be there, the preference tool is
+      # inconsistent, the called method should not return None when
+      # 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):
       """

Modified: erp5/trunk/products/ERP5/__init__.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/__init__.py?rev=37965&r1=37964&r2=37965&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/__init__.py [utf8] (original)
+++ erp5/trunk/products/ERP5/__init__.py [utf8] Tue Aug 24 09:44:53 2010
@@ -52,7 +52,9 @@ from Tool import CategoryTool, Simulatio
                  AcknowledgementTool, SolverTool, SolverProcessTool,\
                  ConversionTool, RoundingTool
 import ERP5Site
+from Document import PythonScript
 object_classes = ( ERP5Site.ERP5Site,
+                   PythonScript.PythonScriptThroughZMI,
                  )
 portal_tools = ( CategoryTool.CategoryTool,
                  SimulationTool.SimulationTool,

Added: erp5/trunk/products/ERP5/dtml/addPythonScriptThroughZMI.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/dtml/addPythonScriptThroughZMI.dtml?rev=37965&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/dtml/addPythonScriptThroughZMI.dtml (added)
+++ erp5/trunk/products/ERP5/dtml/addPythonScriptThroughZMI.dtml [utf8] Tue Aug 24 09:44:53 2010
@@ -0,0 +1,51 @@
+<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>




More information about the Erp5-report mailing list