Commit 9e8c632f authored by Jean-Paul Smets's avatar Jean-Paul Smets

Code contributed by Baye.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19642 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 287df093
......@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
#return the definition string of an object representing a workflow method or a class method or an accessor
def getDefinitionString(obj=None):
......@@ -94,6 +95,13 @@ class AccessorMethodDocumentationHelper(DocumentationHelper):
"""
return self.getDocumentedObject().__name__
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self):
"""
Returns a list of documentation sections for accessors
"""
return []
security.declareProtected( Permissions.AccessContentsInformation, 'getArgCount' )
def getArgCount(self):
"""
......
......@@ -31,7 +31,8 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
class BusinessTemplateDocumentationHelper(DocumentationHelper):
"""
......@@ -48,7 +49,7 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().getTitleOrId()
return self.getDocumentedObject().title
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self):
......@@ -70,15 +71,15 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
uri_list=self.getPortalTypeURIList(),
),
DocumentationSection(
id='workflow',
title='Workflows',
id='dc_workflow',
title='DC Workflows',
class_name='DCWorkflowDocumentationHelper',
uri_list=self.getDCWorkflowURIList(),
),
DocumentationSection(
id='interaction',
id='interaction_workflow',
title='Interaction Workflows',
class_name='InteractionWorkflowStateDocumentationHelper',
class_name='InteractionWorkflowDocumentationHelper',
uri_list=self.getInteractionWorkflowURIList(),
),
DocumentationSection(
......@@ -87,15 +88,184 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
class_name='SkinFolderDocumentationHelper',
uri_list=self.getSkinFolderURIList(),
),
DocumentationSection(
id='module',
title='Module',
class_name='PortalTypeInstanceDocumentationHelper',
uri_list=self.getModuleURIList(),
),
DocumentationSection(
id='catalog_method',
title='Catalog Method',
class_name='CatalogMethodDocumentationHelper',
uri_list=self.getCatalogMethodURIList(),
),
DocumentationSection(
id='base_category',
title='Base Category',
class_name='PortalTypeInstanceDocumentationHelper',
uri_list=self.getBaseCategoryURIList(),
),
])
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the title of the documentation helper
Returns the description of the documentation helper
"""
return self.getDocumentedObject().description
security.declareProtected( Permissions.AccessContentsInformation, 'getVersion' )
def getVersion(self):
"""
Returns the version of the business template
"""
return self.getDocumentedObject().version
security.declareProtected( Permissions.AccessContentsInformation, 'getRevisionNumber' )
def getRevisionNumber(self):
"""
Returns the revision number of the documentation helper
"""
return self.getDocumentedObject().revision
security.declareProtected( Permissions.AccessContentsInformation, 'getBuildingState' )
def getBuildingState(self):
"""
Returns the building_state of the documentation helper
"""
raise NotImplemented
return self.getDocumentedObject().getBuildingState()
security.declareProtected( Permissions.AccessContentsInformation, 'getInstallationState' )
def getInstallationState(self):
"""
Returns the installation_state of the documentation helper
"""
return self.getDocumentedObject().getInstallationState()
security.declareProtected( Permissions.AccessContentsInformation, 'getMaintainerList' )
def getMaintainerList(self):
"""
Returns the list of maintainers of the business template
"""
return self.getDocumentedObject().maintainer
security.declareProtected( Permissions.AccessContentsInformation, 'getDependencyList' )
def getDependencyList(self):
"""
Returns the list of dependencies of the business template
"""
return self.getDocumentedObject().dependency
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeIdList' )
def getPortalTypeIdList(self):
"""
"""
return self.getDocumentedObject().template_portal_type_id
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeURIList' )
def getPortalTypeURIList(self):
"""
"""
portal_type_list = self.getPortalTypeIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_types'
return map(lambda x: ('%s/%s' % (base_uri, x)), portal_type_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getSkinFolderIdList' )
def getSkinFolderIdList(self):
"""
"""
return self.getDocumentedObject().template_skin_id
security.declareProtected( Permissions.AccessContentsInformation, 'getSkinFolderURIList' )
def getSkinFolderURIList(self):
"""
"""
skin_folder_list = self.getSkinFolderIdList()
base_uri = '/' + self.getPortalObject().id + '/portal_skins'
return map(lambda x: ('%s/%s' % (base_uri, x)), skin_folder_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getDCWorkflowIdList' )
def getDCWorkflowIdList(self):
"""
"""
dc_workflow_list = []
for wf in self.getDocumentedObject().template_workflow_id:
url = '/' + self.getPortalObject().id + '/portal_workflow/' + wf
wf_object = self.getPortalObject().unrestrictedTraverse(url)
if wf_object.__class__.__name__ == 'DCWorkflowDefinition':
dc_workflow_list.append(wf)
return dc_workflow_list
security.declareProtected( Permissions.AccessContentsInformation, 'getDCWorkflowURIList' )
def getDCWorkflowURIList(self):
"""
"""
workflow_list = self.getDCWorkflowIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_workflow'
return map(lambda x: ('%s/%s' % (base_uri, x)), workflow_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getInteractionWorkflowIdList' )
def getInteractionWorkflowIdList(self):
"""
"""
workflow_list = []
for wf in self.getDocumentedObject().template_workflow_id:
url = '/' + self.getPortalObject().id + '/portal_workflow/' + wf
wf_object = self.getPortalObject().unrestrictedTraverse(url)
if wf_object.__class__.__name__ == 'InteractionWorkflowDefinition':
workflow_list.append(wf)
return workflow_list
security.declareProtected( Permissions.AccessContentsInformation, 'getInteractionWorkflowURIList' )
def getInteractionWorkflowURIList(self):
"""
"""
workflow_list = self.getInteractionWorkflowIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_workflow'
return map(lambda x: ('%s/%s' % (base_uri, x)), workflow_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getBaseCategoryList' )
def getBaseCategoryList(self):
"""
"""
return self.getDocumentedObject().template_base_category
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeURIList' )
def getBaseCategoryURIList(self):
"""
"""
base_category_list = self.getBaseCategoryList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_categories'
return map(lambda x: ('%s/%s' % (base_uri, x)), base_category_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getModuleIdList' )
def getModuleIdList(self):
"""
"""
return self.getDocumentedObject().template_module_id
security.declareProtected( Permissions.AccessContentsInformation, 'getModuleURIList' )
def getModuleURIList(self):
"""
"""
module_list = self.getModuleIdList()
base_uri = '/'+self.uri.split('/')[1]
return map(lambda x: ('%s/%s' % (base_uri, x)), module_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getCatalogMethodIdList' )
def getCatalogMethodIdList(self):
"""
"""
return self.getDocumentedObject().template_catalog_method_id
security.declareProtected( Permissions.AccessContentsInformation, 'getCatalogMethodURIList' )
def getCatalogMethodURIList(self):
"""
"""
catalog_method_list = self.getCatalogMethodIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_catalog'
return map(lambda x: ('%s/%s' % (base_uri, x)), catalog_method_list)
InitializeClass(BusinessTemplateDocumentationHelper)
......@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class CallableDocumentationHelper(DocumentationHelper):
"""
......
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class CatalogMethodDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a catalog method
"""
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 "Catalog Method"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().id
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getSource' )
def getSource(self):
"""
Returns the source code of the documentation helper
"""
source_code = self.getDocumentedObject().src
if hasattr(self.erp5, 'portal_transforms'):
portal_transforms = self.erp5.portal_transforms
else:
LOG('DCWorkflowScriptDocumentationHelper', INFO,
'Transformation Tool is not installed. No convertion of text 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):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().connection_id
security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList' )
def getArgumentList(self):
"""
Returns the arguments of the documentation helper
"""
return self.getDocumentedObject()._arg._keys
security.declareProtected(Permissions.AccessContentsInformation, 'getCatalog' )
def getCatalog(self):
"""
Returns the catalog name of the documentation helper
"""
return self.getDocumentedObject().aq_parent.__name__
InitializeClass(CatalogMethodDocumentationHelper)
......@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class ClassDocumentationHelper(DocumentationHelper):
"""
......
......@@ -30,6 +30,8 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class ClassMethodDocumentationHelper(DocumentationHelper):
"""
......@@ -56,6 +58,13 @@ class ClassMethodDocumentationHelper(DocumentationHelper):
"""
return self.getDocumentedObject().__name__
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self):
"""
Returns a list of documentation sections for class method
"""
return []
security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' )
def getDefinition(self):
"""
......
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class DCWorkflowPermissionDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a workflow permission
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return "" #self.getDocumentedObject().__dict__["description"]
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow Permission"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return "" #self.getDocumentedObject().__name__
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return "" #self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self):
"""
Returns a list of documentation sections for workflow permissions
"""
return []
InitializeClass(DCWorkflowPermissionDocumentationHelper)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class DCWorkflowScriptDocumentationHelper(DocumentationHelper):
"""
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 self.getDocumentedObject().__name__
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self):
"""
Returns a list of documentation sections for workflow scripts
"""
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
"""
source_code = ""
wf_script = self.getDocumentedObject()
if hasattr(wf_script, '__dict__'):
if '_body' in wf_script.__dict__.keys():
source_code = wf_script.__dict__['_body']
if hasattr(self.erp5, 'portal_transforms'):
portal_transforms = self.erp5.portal_transforms
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)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
def getPermissionsOfRole(state=None, role=''):
"""
Returns list of permissions for a given role with AVMC format above
A = Access contents information
V = View
M = Modify Portal Content
C = Add Portal Content
"""
#LOG('yoooo', INFO, 'state=%s role=%s ' % (state, role))
permissions = ""
if state != None:
if hasattr(state, '__dict__'):
if 'permission_roles' in state.__dict__.keys():
if 'View' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['View']:
permissions += "V"
if 'Access contents information' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Access contents information']:
permissions += "A"
if 'Modify portal content' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Modify portal content']:
permissions += "M"
if 'Add portal content' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Add portal content']:
permissions += "C"
return permissions
class DCWorkflowStateDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a workflow state
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return self.getDocumentedObject().__dict__["description"]
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow State"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().__name__
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().__dict__["title"]
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionList' )
def getTransitionList(self):
"""
Returns list of possible transitions from this state
"""
return self.getDocumentedObject().transitions
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleOwner' )
def getPermissionsOfRoleOwner(self):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Owner')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssignor' )
def getPermissionsOfRoleAssignor(self):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Assignor')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssignee' )
def getPermissionsOfRoleAssignee(self):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Assignee')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssociate' )
def getPermissionsOfRoleAssociate(self):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Associate')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAuthor' )
def getPermissionsOfRoleAuthor(self):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Author')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAuditor' )
def getPermissionsOfRoleAuditor(self):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Auditor')
InitializeClass(DCWorkflowStateDocumentationHelper)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a workflow transition
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return self.getDocumentedObject().__dict__["description"]
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow Transition"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().__name__
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getNewStateId' )
def getNewStateId(self):
"""
Returns the id of the new state for de workflow transition
"""
return self.getDocumentedObject().new_state_id
security.declareProtected(Permissions.AccessContentsInformation, 'getTriggerType' )
def getTriggerType(self):
"""
Returns the trigger type for de workflow transition
"""
trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod']
trigger_type_id = self.getDocumentedObject().trigger_type
return trigger_type_list[trigger_type_id]
security.declareProtected(Permissions.AccessContentsInformation, 'getScriptName' )
def getScriptName(self):
"""
Returns the name of the script for de workflow transition
"""
return self.getDocumentedObject().script_name
security.declareProtected(Permissions.AccessContentsInformation, 'getAfterScriptName' )
def getAfterScriptName(self):
"""
Returns the name of the script for de workflow transition
"""
return self.getDocumentedObject().after_script_name
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableStateIds' )
def getAvailableStateIds(self):
"""
Returns available states in the workflow
"""
return self.getDocumentedObject().getAvailableStateIds()
security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles' )
def getGuardRoles(self):
"""
Returns roles to pass this transition
"""
role_list = ()
if hasattr(self.getDocumentedObject(),'guard'):
dir(self.getDocumentedObject().guard)
if hasattr(self.getDocumentedObject().guard, '__dict__'):
#LOG('baye... 3', INFO, 'dict=%s' % dir(self.getDocumentedObject().guard.__dict__))
#self.getDocumentedObject().guard.__dict__
if 'roles' in self.getDocumentedObject().guard.__dict__.keys():
role_list = self.getDocumentedObject().guard.__dict__['roles']
return ', '.join(role for role in role_list)
InitializeClass(DCWorkflowTransitionDocumentationHelper)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a workflow variable
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return self.getDocumentedObject().__dict__["description"]
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow Variable"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().__name__
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultExpression' )
def getDefaultExpression(self):
"""
Returns the Default Expression of the documentation helper
"""
default_expr = ""
if self.getDocumentedObject().default_expr != None:
default_expr = self.getDocumentedObject().default_expr.text
return default_expr
security.declareProtected(Permissions.AccessContentsInformation, 'getForCatalog' )
def getForCatalog(self):
"""
Returns 1 if variable is available in the catalog
"""
for_catalog = 0
variable = self.getDocumentedObject()
if hasattr(variable, 'for_catalog'):
for_catalog = variable.for_catalog
if for_catalog:
return 'Yes'
else:
return 'No'
security.declareProtected(Permissions.AccessContentsInformation, 'getUpdateAlways' )
def getUpdateAlways(self):
"""
Returns 1 if variable is available in the history
"""
update_always = 0
variable = self.getDocumentedObject()
if hasattr(variable, 'update_always'):
update_always = variable.update_always
if update_always:
return 'Yes'
else:
return 'No'
InitializeClass(DCWorkflowVariableDocumentationHelper)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class DCWorkflowWorklistDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a workflow worklist
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return self.getDocumentedObject().__dict__["description"]
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow Worklist"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().__name__
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
if self.getDocumentedObject().title == "":
return self.getDocumentedObject().actbox_name
else:
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles' )
def getGuardRoles(self):
"""
Returns roles to pass this worklist
"""
role_list = ()
if hasattr(self.getDocumentedObject(),'guard'):
dir(self.getDocumentedObject().guard)
if hasattr(self.getDocumentedObject().guard, '__dict__'):
if 'roles' in self.getDocumentedObject().guard.__dict__.keys():
role_list = self.getDocumentedObject().guard.__dict__['roles']
return ', '.join(role for role in role_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getVarMatches' )
def getVarMatches(self):
"""
Returns variables and values to match worklist
"""
var_matches = {}
if hasattr(self.getDocumentedObject(),'var_matches'):
var_matches = self.getDocumentedObject().var_matches
var_matches_list = []
for key in var_matches.keys():
var_matches_list.append('%s: %s' % (key, ', '.join(x for x in var_matches[key])))
#var_matches_list.append((key, '%s' % ', '.join(x for x in var_matches[key])))
return var_matches_list
InitializeClass(DCWorkflowWorklistDocumentationHelper)
......@@ -30,6 +30,9 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from Products.ERP5Type import Permissions
from App.config import getConfiguration
from zLOG import LOG, INFO
import os
class DocumentationHelper(Implicit):
"""
......@@ -54,23 +57,62 @@ class DocumentationHelper(Implicit):
self.uri = uri
def getDocumentedObject(self):
if '/' in self.uri and '#' not in self.uri:
# URI refers to a portal object
# and is a relative URL
documented_object = self.getPortalObject().portal_categories.resolveCategory(self.uri)
elif '/' in self.uri and '#' in self.uri:
url, method = self.uri.split('#')
# if / in method, method's not an acessor but a workflow method
documented_object = self.getPortalObject().unrestrictedTraverse(url)
if self.uri.startswith('portal_classes/temp_instance'):
url, method = self.uri.split('#')
portal_type = url.split('/')[-1]
temp_folder = self.getPortalObject().portal_classes.newContent(id='temp_instance', portal_type='Folder', temp_object=1)
temp_object = temp_folder.newContent(id=portal_type, portal_type=portal_type, temp_object=1)
if '/' not in method:
documented_object = self.getPortalObject().unrestrictedTraverse(url)
documented_object = getattr(documented_object, method, None)
documented_object = getattr(temp_object, method, None)
else:
#wf_url = 'erp5/portal_workflow/'+method
#documented_object = self.getPortalObject().unrestrictedTraverse(wf_url)
path_method = method.split('/')
wf_method = path_method[len(path_method)-1]
documented_object = getattr(documented_object, wf_method, None)
documented_object = getattr(temp_object, wf_method, None)
elif self.uri.endswith('.py'):
instance_home = getConfiguration().instancehome
file_name = self.uri.split('/')[-1]
file_url = ''
list_path = os.listdir(instance_home+'/Products')
zope_property_sheet = instance_home + '/PropertySheet'
list_propertysheets = [zope_property_sheet,]
for path in list_path:
full_path = instance_home+'/Products/'+path
if os.path.isdir(full_path) and os.path.exists(full_path+'/PropertySheet'):
list_propertysheets.append(full_path+'/PropertySheet')
for propertysheet_directory in list_propertysheets:
if os.path.exists(propertysheet_directory+'/'+file_name):
file_url = propertysheet_directory+'/'+file_name
documented_object = open(file_url)
elif '/' in self.uri and '#' not in self.uri:
# URI refers to a portal object
# and is a relative URL
try:
documented_object = self.getPortalObject().portal_categories.resolveCategory(self.uri)
except:
documented_object = None
if documented_object is None:
documented_object = self.getPortalObject().unrestrictedTraverse(self.uri)
elif '/' in self.uri and '#' in self.uri:
if '?' in self.uri:
base_url, url = self.uri.split('?')
type, name = url.split('#')
parent_object = self.getPortalObject().unrestrictedTraverse(base_url)
object_list = getattr(parent_object, type, None)
documented_object = None
if object_list is not None:
for obj in object_list:
if obj.__name__ == name:
documented_object = obj
else:
url, method = self.uri.split('#')
documented_object = self.getPortalObject().unrestrictedTraverse(url)
if '/' not in method:
documented_object = self.getPortalObject().unrestrictedTraverse(url)
documented_object = getattr(documented_object, method, None)
else:
path_method = method.split('/')
wf_method = path_method[len(path_method)-1]
documented_object = getattr(documented_object, wf_method, None)
else:
# URI refers to a python class / method
import imp
......@@ -82,13 +124,12 @@ class DocumentationHelper(Implicit):
import Products
documented_object = Products
for key in module_list[1:]:
LOG('loop in module_list', 0, repr(documented_object))
#LOG('Baye, loop in module_list', 0,'do=%s et uri=%s' % (repr(documented_object), self.uri))
documented_object = getattr(documented_object, key)
else:
raise NotImplemented
#fp, pathname, description = imp.find_module(base_module)
#documented_object = imp.load_module(fp, pathname, description)
return documented_object
def getTitle(self):
......@@ -110,7 +151,7 @@ class DocumentationHelper(Implicit):
"""
Returns a list of documentation sections
"""
raise NotImplemented
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getURI')
def getURI(self):
......
......@@ -30,12 +30,12 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from Products.ERP5Type import Permissions
from Products.PythonScripts.Utility import allow_class
class DocumentationSection(Implicit):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# security = ClassSecurityInfo()
# security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, id, title, class_name, uri_list):
self.id = id
......@@ -43,14 +43,15 @@ class DocumentationSection(Implicit):
self.class_name = class_name
self.uri_list = uri_list
security.declareProtected(Permissions.AccessContentsInformation, 'getClassName')
# security.declareProtected(Permissions.AccessContentsInformation, 'getClassName')
def getClassName(self):
return self.class_name
security.declareProtected(Permissions.AccessContentsInformation, 'getURIList')
# security.declareProtected(Permissions.AccessContentsInformation, 'getURIList')
def getURIList(self):
return self.uri_list
# more API needed XXX
InitializeClass(DocumentationSection)
#InitializeClass(DocumentationSection)
allow_class(DocumentationSection)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class ERP5FormDocumentationHelper(DocumentationHelper):
"""
Provides documentation about an ERP5 Form
"""
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 "ERP5 Form"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().id
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected( Permissions.AccessContentsInformation, 'getEncoding' )
def getEncoding(self):
"""
Returns the encoding of the ERP5 Form
"""
return self.getDocumentedObject().encoding
InitializeClass(ERP5FormDocumentationHelper)
......@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class InstancePropertyDocumentationHelper(DocumentationHelper):
"""
......
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class PageTemplateDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a page template
"""
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 "Page Template"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().id
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' )
def getSourceCode(self):
"""
Returns the source code the script python
"""
source_code = self.getDocumentedObject()._text
if hasattr(self.erp5, 'portal_transforms'):
portal_transforms = self.erp5.portal_transforms
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()
InitializeClass(PageTemplateDocumentationHelper)
......@@ -33,4 +33,4 @@ from DocumentationHelper import DocumentationHelper
class PortalDocumentationHelper(DocumentationHelper):
"""
"""
\ No newline at end of file
"""
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class PortalTypeActionDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a portal type action
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return self.getDocumentedObject().Description()
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Portal Type Action"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().__name__
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissions' )
def getPermissions(self):
"""
Returns the permissions of the documentation helper
"""
return ', '.join(x for x in self.getDocumentedObject().permissions)
security.declareProtected(Permissions.AccessContentsInformation, 'getVisible' )
def getVisible(self):
"""
Returns the visibility of the documentation helper
"""
TITLE =['No', 'Yes']
return TITLE[self.getDocumentedObject().visible]
security.declareProtected(Permissions.AccessContentsInformation, 'getCategory' )
def getCategory(self):
"""
Returns the category of the documentation helper
"""
return self.getDocumentedObject().category
InitializeClass(PortalTypeActionDocumentationHelper)
......@@ -30,7 +30,8 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
"""
......@@ -68,12 +69,6 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
Returns a list of documentation sections
"""
return [
#DocumentationSection(
#id='instance_property',
#title='Instance Properties',
#class_name='InstancePropertyDocumentationHelper',
#uri_list=self.getClassPropertyURIList(),
#),
DocumentationSection(
id='workflow_method',
title='Workflow Method',
......@@ -112,7 +107,7 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
return self._getPropertyHolder().getAccessorMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' )
def getAccessorMethodIdList(self):
def getAccessorMethodIdList(self, inherited=1):
"""
"""
return self._getPropertyHolder().getAccessorMethodIdList()
......@@ -122,7 +117,7 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
"""
Returns a list of URIs to accessor methods
"""
method_id_list = self.getAccessorMethodIdList(inherited=inherited, local=local)
method_id_list = self.getAccessorMethodIdList(inherited=inherited)
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
......@@ -142,20 +137,21 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
return self._getPropertyHolder()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' )
def getWorkflowMethodIdList(self):
def getWorkflowMethodIdList(self, inherited=1):
"""
"""
return self._getPropertyHolder().getWorkflowMethodIdList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodURIList' )
def getWorkflowMethodURIList(self, inherited=1, local=1):
"""
Returns a list of URIs to workflow methods
"""
method_id_list = self.getWorkflowMethodIdList(inherited=inherited, local=local)
method_id_list = self.getWorkflowMethodIdList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
uri_prefix = '' #'%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
......
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class PortalTypePropertySheetDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a property sheet of a portal type
"""
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 "Property Sheet"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().name.split("/")[-1]
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().name
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' )
def getSourceCode(self):
"""
Returns the source code the property sheet
"""
source_code = ""
property_sheet_file = self.getDocumentedObject()
if property_sheet_file is not None:
property_sheet_file.seek(0)
source_code = property_sheet_file.read()
if hasattr(self.erp5, 'portal_transforms'):
portal_transforms = self.erp5.portal_transforms
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(PortalTypePropertySheetDocumentationHelper)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class PortalTypeRoleDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a portal type role definition
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return self.getDocumentedObject().Description()
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Portal Type Role"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().__name__
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getCategoryList' )
def getCategoryList(self):
"""
Returns the list of categories for the role
"""
return self.getDocumentedObject().category
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryScript' )
def getBaseCategoryScript(self):
"""
Returns the base category script of the role
"""
return self.getDocumentedObject().base_category_script
InitializeClass(PortalTypeRoleDocumentationHelper)
......@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class PropertyDocumentationHelper(DocumentationHelper):
"""
......
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class ScriptPythonDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a pyhton 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 "Script Python"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().id
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' )
def getSourceCode(self):
"""
Returns the source code the script python
"""
source_code = self.getDocumentedObject()._body
if hasattr(self.erp5, 'portal_transforms'):
portal_transforms = self.erp5.portal_transforms
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(ScriptPythonDocumentationHelper)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class SkinFolderDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a property sheet of a skin folder
"""
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 "Skin Folder"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().id
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getMetaTypeList' )
def getMetaTypeList(self):
meta_type_dict = {}
for file in self.getDocumentedObject().objectValues():
meta_type_dict[file.meta_type] = None
type_list = meta_type_dict.keys()
type_list.sort()
return type_list
security.declareProtected(Permissions.AccessContentsInformation, 'getFileIdList' )
def getFileIdList(self, meta_type=None):
"""
Returns the list of sub-objects ids of the documentation helper
"""
file_list = []
for file in self.getDocumentedObject().objectValues():
if not meta_type or file.meta_type == meta_type:
file_list.append(file.id)
return file_list
security.declareProtected(Permissions.AccessContentsInformation, 'getFileItemList' )
def getFileItemList(self, meta_type=None):
"""
Returns the list of sub-objects items of the documentation helper
"""
file_list = []
for file in self.getDocumentedObject().objectValues():
if not meta_type or file.meta_type == meta_type:
file_list.append((file.id, file.title, file.meta_type))
return file_list
InitializeClass(SkinFolderDocumentationHelper)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class SkinFolderItemDocumentationHelper(DocumentationHelper):
"""
Provides documentation about an Skin Folder Item
"""
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 self.getDocumentedObject().meta_type
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().id
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getContentType' )
def getContentType(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().content_type
InitializeClass(SkinFolderItemDocumentationHelper)
......@@ -30,6 +30,8 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class WorkflowMethodDocumentationHelper(DocumentationHelper):
"""
......@@ -60,6 +62,14 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper):
"""
return self.getDocumentedObject().__name__
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
#security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationState' )
#def getDestinationState(self):
# """
......@@ -97,5 +107,4 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper):
"""
return getDefinitionString(self.getDocumentedObject())
InitializeClass(WorkflowMethodDocumentationHelper)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class ZSQLMethodDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a Z SQL Method
"""
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 "Z SQL Method"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().id
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getSource' )
def getSource(self):
"""
Returns the source code of the documentation helper
"""
source_code = self.getDocumentedObject().src
if hasattr(self.erp5, 'portal_transforms'):
portal_transforms = self.erp5.portal_transforms
else:
LOG('DCWorkflowScriptDocumentationHelper', INFO,
'Transformation Tool is not installed. No convertion of text 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):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().connection_id
security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList' )
def getArgumentList(self):
"""
Returns the arguments of the documentation helper
"""
return self.getDocumentedObject().arguments_src
security.declareProtected(Permissions.AccessContentsInformation, 'getClassName' )
def getClassName(self):
"""
Returns the class name of the documentation helper
"""
return self.getDocumentedObject().class_name_
security.declareProtected(Permissions.AccessContentsInformation, 'getClassFile' )
def getClassFile(self):
"""
Returns the class file of the documentation helper
"""
return self.getDocumentedObject().class_file_
security.declareProtected(Permissions.AccessContentsInformation, 'getMaxRows' )
def getMaxRows(self):
"""
Returns the of the documentation helper
"""
return self.getDocumentedObject().max_rows_
InitializeClass(ZSQLMethodDocumentationHelper)
......@@ -41,5 +41,23 @@ from InstancePropertyDocumentationHelper import InstancePropertyDocumentationHel
from PortalDocumentationHelper import PortalDocumentationHelper
from PortalTypeDocumentationHelper import PortalTypeDocumentationHelper
from PortalTypeInstanceDocumentationHelper import PortalTypeInstanceDocumentationHelper
from PortalTypeRoleDocumentationHelper import PortalTypeRoleDocumentationHelper
from PortalTypeActionDocumentationHelper import PortalTypeActionDocumentationHelper
from PortalTypePropertySheetDocumentationHelper import PortalTypePropertySheetDocumentationHelper
from PropertyDocumentationHelper import PropertyDocumentationHelper
from WorkflowMethodDocumentationHelper import WorkflowMethodDocumentationHelper
\ No newline at end of file
from WorkflowMethodDocumentationHelper import WorkflowMethodDocumentationHelper
from DCWorkflowStateDocumentationHelper import DCWorkflowStateDocumentationHelper
from DCWorkflowTransitionDocumentationHelper import DCWorkflowTransitionDocumentationHelper
from DCWorkflowVariableDocumentationHelper import DCWorkflowVariableDocumentationHelper
from DCWorkflowPermissionDocumentationHelper import DCWorkflowPermissionDocumentationHelper
from DCWorkflowWorklistDocumentationHelper import DCWorkflowWorklistDocumentationHelper
from DCWorkflowScriptDocumentationHelper import DCWorkflowScriptDocumentationHelper
from SkinFolderDocumentationHelper import SkinFolderDocumentationHelper
from InteractionWorkflowDocumentationHelper import InteractionWorkflowDocumentationHelper
from CatalogMethodDocumentationHelper import CatalogMethodDocumentationHelper
from SkinFolderItemDocumentationHelper import SkinFolderItemDocumentationHelper
from ScriptPythonDocumentationHelper import ScriptPythonDocumentationHelper
from ERP5FormDocumentationHelper import ERP5FormDocumentationHelper
from PageTemplateDocumentationHelper import PageTemplateDocumentationHelper
from ZSQLMethodDocumentationHelper import ZSQLMethodDocumentationHelper
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