From 843c4d06e6e738aff2d7e67496073f1037a31a7d Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Thu, 20 Nov 2008 09:11:33 +0000 Subject: [PATCH] - Merged ScriptPythonDocumentationHelper and DCWorkflowScriptDocumentationHelper - Merged CatalogMethodDocumentationHelper and ZSQLMethodDocumentationHelper - Improve the rendering of parameters of python scripts git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24644 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../AccessorMethodDocumentationHelper.py | 5 ++ .../CatalogMethodDocumentationHelper.py | 26 +------- .../DCWorkflowScriptDocumentationHelper.py | 65 +------------------ .../ScriptPythonDocumentationHelper.py | 8 +++ 4 files changed, 17 insertions(+), 87 deletions(-) diff --git a/product/ERP5Type/DocumentationHelper/AccessorMethodDocumentationHelper.py b/product/ERP5Type/DocumentationHelper/AccessorMethodDocumentationHelper.py index fdf96543dc..2d10fe73bb 100644 --- a/product/ERP5Type/DocumentationHelper/AccessorMethodDocumentationHelper.py +++ b/product/ERP5Type/DocumentationHelper/AccessorMethodDocumentationHelper.py @@ -46,6 +46,11 @@ def getDefinitionString(obj=None): fc.append('*args') elif fc_var_names[i] == 'kw': fc.append('**kw') + elif fc_var_names[i].startswith('_') or \ + fc_var_names[i].startswith('Products'): + # In case of python scripts, we have many things + # that we do not want to display + break else: fc.append(fc_var_names[i]) fd = obj.func_defaults diff --git a/product/ERP5Type/DocumentationHelper/CatalogMethodDocumentationHelper.py b/product/ERP5Type/DocumentationHelper/CatalogMethodDocumentationHelper.py index e382c9d49e..2295293b21 100644 --- a/product/ERP5Type/DocumentationHelper/CatalogMethodDocumentationHelper.py +++ b/product/ERP5Type/DocumentationHelper/CatalogMethodDocumentationHelper.py @@ -29,10 +29,10 @@ from Acquisition import Implicit from AccessControl import ClassSecurityInfo from Globals import InitializeClass -from DocumentationHelper import DocumentationHelper +from ZSQLMethodDocumentationHelper import ZSQLMethodDocumentationHelper from Products.ERP5Type import Permissions -class CatalogMethodDocumentationHelper(DocumentationHelper): +class CatalogMethodDocumentationHelper(ZSQLMethodDocumentationHelper): """ Provides documentation about a catalog method """ @@ -63,28 +63,6 @@ class CatalogMethodDocumentationHelper(DocumentationHelper): """ return getattr(self.getDocumentedObject(), 'title', '') - security.declareProtected(Permissions.AccessContentsInformation, 'getSource' ) - def getSource(self): - """ - Returns the source code the catalog method - """ - from zLOG import LOG, INFO - source_code = getattr(self.getDocumentedObject(), 'src', '') - portal_transforms = getattr(self, 'portal_transforms', None) - if portal_transforms is not None: - REQUEST = getattr(self, 'REQUEST', None) - if REQUEST is not None: - if REQUEST.get('portal_skin', 'View' ) != 'View': - return source_code - else: - LOG('DCWorkflowScriptDocumentationHelper', INFO, - 'Transformation Tool is not installed. No convertion of python script to html') - return source_code - src_mimetype='text/plain' - mime_type = 'text/html' - source_html = portal_transforms.convertTo(mime_type, source_code, mimetype = src_mimetype) - return source_html.getData() - security.declareProtected(Permissions.AccessContentsInformation, 'getConnectionId' ) def getConnectionId(self): """ diff --git a/product/ERP5Type/DocumentationHelper/DCWorkflowScriptDocumentationHelper.py b/product/ERP5Type/DocumentationHelper/DCWorkflowScriptDocumentationHelper.py index 6b3921c42b..2bdf04c60d 100644 --- a/product/ERP5Type/DocumentationHelper/DCWorkflowScriptDocumentationHelper.py +++ b/product/ERP5Type/DocumentationHelper/DCWorkflowScriptDocumentationHelper.py @@ -29,42 +29,16 @@ from Acquisition import Implicit from AccessControl import ClassSecurityInfo from Globals import InitializeClass -from DocumentationHelper import DocumentationHelper +from ScriptPythonDocumentationHelper import ScriptPythonDocumentationHelper from Products.ERP5Type import Permissions -from AccessorMethodDocumentationHelper import getDefinitionString -class DCWorkflowScriptDocumentationHelper(DocumentationHelper): +class DCWorkflowScriptDocumentationHelper(ScriptPythonDocumentationHelper): """ Provides documentation about a workflow script """ security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) - def __init__(self, uri): - self.uri = uri - - security.declareProtected(Permissions.AccessContentsInformation, 'getType' ) - def getType(self): - """ - Returns the type of the documentation helper - """ - return "Workflow Script" - - security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) - def getId(self): - """ - Returns the id of the documentation helper - """ - return getattr(self.getDocumentedObject(), "__name__", "") - - - security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) - def getTitle(self): - """ - Returns the title of the documentation helper - """ - return getattr(self.getDocumentedObject(), "title", "") - security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList') def getSectionList(self): """ @@ -72,39 +46,4 @@ class DCWorkflowScriptDocumentationHelper(DocumentationHelper): """ return [] - security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' ) - def getDefinition(self): - """ - Returns the definition of the script with the name of the script and arguments - """ - return getDefinitionString(self.getDocumentedObject()) - - security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' ) - def getSourceCode(self): - """ - Returns the source code the workflow script - """ - from zLOG import LOG, INFO - source_code = "" - wf_script = self.getDocumentedObject() - source_code = wf_script.document_src() - portal_transforms = getattr(self, 'portal_transforms', None) - if portal_transforms is not None: - REQUEST = getattr(self, 'REQUEST', None) - if REQUEST is not None: - if REQUEST.get('portal_skin', 'View' ) != 'View': - doc_string = source_code.split('"""') - if len(doc_string)>1 and not doc_string[0]: - return doc_string[1] - else: - return "" - else: - LOG('DCWorkflowScriptDocumentationHelper', INFO, - 'Transformation Tool is not installed. No convertion of python script to html') - return source_code - src_mimetype='text/x-python' - mime_type = 'text/html' - source_html = portal_transforms.convertTo(mime_type, source_code, mimetype = src_mimetype) - return source_html.getData() - InitializeClass(DCWorkflowScriptDocumentationHelper) diff --git a/product/ERP5Type/DocumentationHelper/ScriptPythonDocumentationHelper.py b/product/ERP5Type/DocumentationHelper/ScriptPythonDocumentationHelper.py index 55cec79156..4b994f84fd 100644 --- a/product/ERP5Type/DocumentationHelper/ScriptPythonDocumentationHelper.py +++ b/product/ERP5Type/DocumentationHelper/ScriptPythonDocumentationHelper.py @@ -31,6 +31,7 @@ from AccessControl import ClassSecurityInfo from Globals import InitializeClass from DocumentationHelper import DocumentationHelper from Products.ERP5Type import Permissions +from AccessorMethodDocumentationHelper import getDefinitionString class ScriptPythonDocumentationHelper(DocumentationHelper): """ @@ -89,4 +90,11 @@ class ScriptPythonDocumentationHelper(DocumentationHelper): source_html = portal_transforms.convertTo(mime_type, source_code, mimetype = src_mimetype) return source_html.getData() + security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' ) + def getDefinition(self): + """ + Returns the definition of the script with the name of the script and arguments + """ + return getDefinitionString(self.getDocumentedObject()) + InitializeClass(ScriptPythonDocumentationHelper) -- 2.30.9