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 ...@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper 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 #return the definition string of an object representing a workflow method or a class method or an accessor
def getDefinitionString(obj=None): def getDefinitionString(obj=None):
...@@ -94,6 +95,13 @@ class AccessorMethodDocumentationHelper(DocumentationHelper): ...@@ -94,6 +95,13 @@ class AccessorMethodDocumentationHelper(DocumentationHelper):
""" """
return self.getDocumentedObject().__name__ 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' ) security.declareProtected( Permissions.AccessContentsInformation, 'getArgCount' )
def getArgCount(self): def getArgCount(self):
""" """
......
...@@ -31,7 +31,8 @@ from Acquisition import Implicit ...@@ -31,7 +31,8 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
class BusinessTemplateDocumentationHelper(DocumentationHelper): class BusinessTemplateDocumentationHelper(DocumentationHelper):
""" """
...@@ -48,7 +49,7 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -48,7 +49,7 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().getTitleOrId() return self.getDocumentedObject().title
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -70,15 +71,15 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -70,15 +71,15 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
uri_list=self.getPortalTypeURIList(), uri_list=self.getPortalTypeURIList(),
), ),
DocumentationSection( DocumentationSection(
id='workflow', id='dc_workflow',
title='Workflows', title='DC Workflows',
class_name='DCWorkflowDocumentationHelper', class_name='DCWorkflowDocumentationHelper',
uri_list=self.getDCWorkflowURIList(), uri_list=self.getDCWorkflowURIList(),
), ),
DocumentationSection( DocumentationSection(
id='interaction', id='interaction_workflow',
title='Interaction Workflows', title='Interaction Workflows',
class_name='InteractionWorkflowStateDocumentationHelper', class_name='InteractionWorkflowDocumentationHelper',
uri_list=self.getInteractionWorkflowURIList(), uri_list=self.getInteractionWorkflowURIList(),
), ),
DocumentationSection( DocumentationSection(
...@@ -87,15 +88,184 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -87,15 +88,184 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
class_name='SkinFolderDocumentationHelper', class_name='SkinFolderDocumentationHelper',
uri_list=self.getSkinFolderURIList(), 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 # Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' ) security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self): 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) InitializeClass(BusinessTemplateDocumentationHelper)
...@@ -30,6 +30,7 @@ from Acquisition import Implicit ...@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class CallableDocumentationHelper(DocumentationHelper): 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 ...@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class ClassDocumentationHelper(DocumentationHelper): class ClassDocumentationHelper(DocumentationHelper):
""" """
......
...@@ -30,6 +30,8 @@ from Acquisition import Implicit ...@@ -30,6 +30,8 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class ClassMethodDocumentationHelper(DocumentationHelper): class ClassMethodDocumentationHelper(DocumentationHelper):
""" """
...@@ -56,6 +58,13 @@ class ClassMethodDocumentationHelper(DocumentationHelper): ...@@ -56,6 +58,13 @@ class ClassMethodDocumentationHelper(DocumentationHelper):
""" """
return self.getDocumentedObject().__name__ 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' ) security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' )
def getDefinition(self): def getDefinition(self):
""" """
......
...@@ -30,6 +30,30 @@ from Acquisition import Implicit ...@@ -30,6 +30,30 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph
def getStatePermissionsOfRole(state=None, 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 DCWorkflowDocumentationHelper(DocumentationHelper): class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
...@@ -40,13 +64,19 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -40,13 +64,19 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
def getInstance(self):
return self.getPortalObject().restrictedTraverse(self.uri)
# API Implementation # API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected( Permissions.AccessContentsInformation, 'getId' )
def getTitle(self): def getId(self):
""" """
Returns the title of the documentation helper Returns the Id of the documentation helper
""" """
return self.getDocumentedObject().getTitleOrId() return self.getInstance().__name__
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -55,6 +85,21 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -55,6 +85,21 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
return "DC Workflow" return "DC Workflow"
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getInstance().__dict__["title"]
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the description of the documentation helper
"""
return self.getInstance().__dict__["description"]
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self): def getSectionList(self):
""" """
...@@ -65,72 +110,298 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -65,72 +110,298 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
id='state', id='state',
title='Workflow States', title='Workflow States',
class_name='DCWorkflowStateDocumentationHelper', class_name='DCWorkflowStateDocumentationHelper',
uri_list=self.getStateURIList(), uri_list=self.getStateUriList(),
), ),
DocumentationSection( DocumentationSection(
id='transition', id='transition',
title='Workflow Transitions', title='Workflow Transitions',
class_name='DCWorkflowTransitionDocumentationHelper', class_name='DCWorkflowTransitionDocumentationHelper',
uri_list=self.getStateURIList(), uri_list=self.getTransitionUriList(),
), ),
DocumentationSection( DocumentationSection(
id='variable', id='variable',
title='Workflow Variables', title='Workflow Variables',
class_name='DCWorkflowVariableDocumentationHelper', class_name='DCWorkflowVariableDocumentationHelper',
uri_list=self.getVariableURIList(), uri_list=self.getVariableUriList(),
), ),
DocumentationSection( DocumentationSection(
id='variable', id='permission',
title='Workflow Permissions', title='Workflow Permissions',
class_name='PermissionDocumentationHelper', class_name='DCWorkflowPermissionDocumentationHelper',
uri_list=self.getPermissionURIList(), uri_list=self.getPermissionUriList(),
),
DocumentationSection(
id='worklist',
title='Workflow Worklists',
class_name='DCWorkflowWorklistDocumentationHelper',
uri_list=self.getWorklistUriList(),
),
DocumentationSection(
id='script',
title='Workflow Scripts',
class_name='DCWorkflowScriptDocumentationHelper',
uri_list=self.getScriptUriList(),
), ),
]) ])
# Specific methods # Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' ) security.declareProtected( Permissions.AccessContentsInformation, 'getStateIdList' )
def getDescription(self): def getStateIdList(self):
""" """
Returns the title of the documentation helper
""" """
raise NotImplemented state_list = []
for state in self.getInstance().states.objectValues():
state_list.append(state.getId())
return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getStateItemList' )
def getVariableURIList(self): def getStateItemList(self):
"""
""" """
state_list = []
for state in self.getInstance().states.objectValues():
state_list.append((state.getId(),
state.__dict__["title"],
getStatePermissionsOfRole(state, 'Owner'),
getStatePermissionsOfRole(state, 'Assignor'),
getStatePermissionsOfRole(state, 'Assignee'),
getStatePermissionsOfRole(state, 'Associate'),
getStatePermissionsOfRole(state, 'Author'),
getStatePermissionsOfRole(state, 'Auditor')
))
return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateUriList' )
def getStateUriList(self):
""" """
raise NotImplemented """
state_id_list = self.getStateIdList()
return map(lambda x: ('%s/states/%s' % (self.uri, x)), state_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getStateURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getStateURIList' )
def getStateURIList(self): def getStateURIList(self):
""" """
""" """
raise NotImplemented state_item_list = self.getStateItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4], x[5], x[6], x[7]), state_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionIdList' )
def getTransitionIdList(self):
"""
"""
transition_list = []
for transition in self.getInstance().transitions.objectValues():
transition_list.append(transition.getId())
return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionItemList' )
def getTransitionItemList(self):
"""
"""
transition_list = []
trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod']
for transition in self.getInstance().transitions.objectValues():
guard_roles = ""
guard = dir(transition.guard)
if hasattr(transition.guard, '__dict__'):
if 'roles' in transition.guard.__dict__.keys():
guard_roles = ', '.join(role for role in transition.guard.__dict__['roles'])
transition_list.append((transition.getId(),
transition.title,
trigger_type_list[transition.trigger_type],
transition.__dict__["description"],
guard_roles
))
return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionUriList' )
def getTransitionUriList(self):
"""
"""
transition_id_list = self.getTransitionIdList()
return map(lambda x: ('%s/transitions/%s' % (self.uri, x)), transition_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionURIList' )
def getTransitionURIList(self):
"""
"""
transition_item_list = self.getTransitionItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4]), transition_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableIdList' )
def getVariableIdList(self):
"""
"""
variable_list = []
for variable in self.getInstance().variables.objectValues():
variable_list.append(variable.getId())
return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableItemList' )
def getVariableItemList(self):
"""
"""
variable_list = []
for variable in self.getInstance().variables.objectValues():
variable_list.append((variable.getId(), variable.title, variable.__dict__["description"]))
return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' )
def getVariableURIList(self): def getVariableURIList(self):
""" """
""" """
raise NotImplemented variable_item_list = self.getVariableItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2]), variable_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableUriList' )
def getVariableUriList(self):
"""
"""
variable_id_list = self.getVariableIdList()
return map(lambda x: ('%s/variables/%s' % (self.uri, x)), variable_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionIdList' )
def getPermissionIdList(self):
"""
"""
permission_list = []
for permission in self.getInstance().permissions:
permission_list.append(permission)
return permission_list
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionURIList' )
def getPermissionURIList(self): def getPermissionURIList(self):
""" """
""" """
raise NotImplemented permission_id_list = self.getPermissionIdList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), permission_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionUriList' )
def getPermissionUriList(self):
"""
"""
permission_id_list = self.getPermissionIdList()
return map(lambda x: '%s/permissions/%s' % (self.uri, x), permission_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistIdList' )
def getWorklistIdList(self):
"""
"""
worklist_list = []
for wl in self.getInstance().worklists.objectValues():
worklist_list.append(wl.__name__)
return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistItemList' )
def getWorklistItemList(self):
"""
"""
worklist_list = []
for wl in self.getInstance().worklists.objectValues():
guard_roles = ""
guard = dir(wl.guard)
if wl.title == "":
title = wl.actbox_name
else:
title = wl.title
if hasattr(wl.guard, '__dict__'):
if 'roles' in wl.guard.__dict__.keys():
guard_roles = ', '.join(role for role in wl.guard.__dict__['roles'])
worklist_list.append((wl.__name__, title, wl.__dict__["description"],guard_roles))
return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistURIList' )
def getWorklistURIList(self):
"""
"""
worklist_item_list = self.getWorklistItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3]), worklist_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistUriList' )
def getWorklistUriList(self):
"""
"""
worklist_id_list = self.getWorklistIdList()
return map(lambda x: ('%s/worklists/%s' % (self.uri, x)), worklist_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptIdList' )
def getScriptIdList(self):
"""
"""
script_list = []
for script in self.getInstance().scripts.objectValues():
script_list.append(script.__name__)
return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptItemList' )
def getScriptItemList(self):
"""
"""
script_list = []
for script in self.getInstance().scripts.objectValues():
#guard_roles = ""
#guard = dir(script.guard)
#if hasattr(script.guard, '__dict__'):
# if 'roles' in script.guard.__dict__.keys():
# guard_roles = ', '.join(role for role in script.guard.__dict__['roles'])
script_list.append((script.__name__, script.title))
return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptURIList' )
def getScriptURIList(self):
"""
"""
script_item_list = self.getScriptItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1]), script_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptUriList' )
def getScriptUriList(self):
"""
"""
script_id_list = self.getScriptIdList()
return map(lambda x: ('%s/scripts/%s' % (self.uri, x)), script_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageURL' ) security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageURL' )
def getGraphImageURL(self): def getGraphImageURL(self):
""" """
Returns a URL to a graphic representation of the workflow Returns a URL to a graphic representation of the workflow
""" """
raise NotImplemented ""
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageData' ) security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageData' )
def getGraphImageData(self): def getGraphImageData(self, format='png'):
""" """
Returns the graphic representation of the workflow as a PNG file Returns the graphic representation of the workflow as a PNG file
""" """
raise NotImplemented return getGraph(self, wf_id=self.getInstance().__name__, format=format)
InitializeClass(DCWorkflowDocumentationHelper) InitializeClass(DCWorkflowDocumentationHelper)
##############################################################################
#
# 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 ...@@ -30,6 +30,9 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from App.config import getConfiguration
from zLOG import LOG, INFO
import os
class DocumentationHelper(Implicit): class DocumentationHelper(Implicit):
""" """
...@@ -54,20 +57,59 @@ class DocumentationHelper(Implicit): ...@@ -54,20 +57,59 @@ class DocumentationHelper(Implicit):
self.uri = uri self.uri = uri
def getDocumentedObject(self): def getDocumentedObject(self):
if '/' in self.uri and '#' not in self.uri: 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 = getattr(temp_object, method, None)
else:
path_method = method.split('/')
wf_method = path_method[len(path_method)-1]
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 # URI refers to a portal object
# and is a relative URL # and is a relative URL
try:
documented_object = self.getPortalObject().portal_categories.resolveCategory(self.uri) 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: 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('#') url, method = self.uri.split('#')
# if / in method, method's not an acessor but a workflow method
documented_object = self.getPortalObject().unrestrictedTraverse(url) documented_object = self.getPortalObject().unrestrictedTraverse(url)
if '/' not in method: if '/' not in method:
documented_object = self.getPortalObject().unrestrictedTraverse(url) documented_object = self.getPortalObject().unrestrictedTraverse(url)
documented_object = getattr(documented_object, method, None) documented_object = getattr(documented_object, method, None)
else: else:
#wf_url = 'erp5/portal_workflow/'+method
#documented_object = self.getPortalObject().unrestrictedTraverse(wf_url)
path_method = method.split('/') path_method = method.split('/')
wf_method = path_method[len(path_method)-1] wf_method = path_method[len(path_method)-1]
documented_object = getattr(documented_object, wf_method, None) documented_object = getattr(documented_object, wf_method, None)
...@@ -82,13 +124,12 @@ class DocumentationHelper(Implicit): ...@@ -82,13 +124,12 @@ class DocumentationHelper(Implicit):
import Products import Products
documented_object = Products documented_object = Products
for key in module_list[1:]: 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) documented_object = getattr(documented_object, key)
else: else:
raise NotImplemented raise NotImplemented
#fp, pathname, description = imp.find_module(base_module) #fp, pathname, description = imp.find_module(base_module)
#documented_object = imp.load_module(fp, pathname, description) #documented_object = imp.load_module(fp, pathname, description)
return documented_object return documented_object
def getTitle(self): def getTitle(self):
...@@ -110,7 +151,7 @@ class DocumentationHelper(Implicit): ...@@ -110,7 +151,7 @@ class DocumentationHelper(Implicit):
""" """
Returns a list of documentation sections Returns a list of documentation sections
""" """
raise NotImplemented return []
security.declareProtected(Permissions.AccessContentsInformation, 'getURI') security.declareProtected(Permissions.AccessContentsInformation, 'getURI')
def getURI(self): def getURI(self):
......
...@@ -30,12 +30,12 @@ from Acquisition import Implicit ...@@ -30,12 +30,12 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.PythonScripts.Utility import allow_class
class DocumentationSection(Implicit): class DocumentationSection(Implicit):
security = ClassSecurityInfo() # security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) # security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, id, title, class_name, uri_list): def __init__(self, id, title, class_name, uri_list):
self.id = id self.id = id
...@@ -43,14 +43,15 @@ class DocumentationSection(Implicit): ...@@ -43,14 +43,15 @@ class DocumentationSection(Implicit):
self.class_name = class_name self.class_name = class_name
self.uri_list = uri_list self.uri_list = uri_list
security.declareProtected(Permissions.AccessContentsInformation, 'getClassName') # security.declareProtected(Permissions.AccessContentsInformation, 'getClassName')
def getClassName(self): def getClassName(self):
return self.class_name return self.class_name
security.declareProtected(Permissions.AccessContentsInformation, 'getURIList') # security.declareProtected(Permissions.AccessContentsInformation, 'getURIList')
def getURIList(self): def getURIList(self):
return self.uri_list return self.uri_list
# more API needed XXX # 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 ...@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class InstancePropertyDocumentationHelper(DocumentationHelper): 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 DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph
def getStatePermissionsOfRole(state=None, 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 InteractionWorkflowDocumentationHelper(DocumentationHelper):
"""
Provides access to all documentation information
of an interaction workflow.
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
def getInstance(self):
return self.getPortalObject().restrictedTraverse(self.uri)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the Id of the documentation helper
"""
return self.getInstance().__name__
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Interaction Workflow"
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getInstance().__dict__["title"]
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the description of the documentation helper
"""
return self.getInstance().__dict__["description"]
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return map(lambda x: x.__of__(self), [
DocumentationSection(
id='state',
title='Workflow States',
class_name='DCWorkflowStateDocumentationHelper',
uri_list=self.getStateUriList(),
),
DocumentationSection(
id='transition',
title='Workflow Transitions',
class_name='DCWorkflowTransitionDocumentationHelper',
uri_list=self.getTransitionUriList(),
),
DocumentationSection(
id='variable',
title='Workflow Variables',
class_name='DCWorkflowVariableDocumentationHelper',
uri_list=self.getVariableUriList(),
),
DocumentationSection(
id='permission',
title='Workflow Permissions',
class_name='DCWorkflowPermissionDocumentationHelper',
uri_list=self.getPermissionUriList(),
),
DocumentationSection(
id='worklist',
title='Workflow Worklists',
class_name='DCWorkflowWorklistDocumentationHelper',
uri_list=self.getWorklistUriList(),
),
DocumentationSection(
id='script',
title='Workflow Scripts',
class_name='DCWorkflowScriptDocumentationHelper',
uri_list=self.getScriptUriList(),
),
])
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getStateIdList' )
def getStateIdList(self):
"""
"""
state_list = []
for state in self.getInstance().states.objectValues():
state_list.append(state.getId())
return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateItemList' )
def getStateItemList(self):
"""
"""
state_list = []
for state in self.getInstance().states.objectValues():
state_list.append((state.getId(),
state.__dict__["title"],
getStatePermissionsOfRole(state, 'Owner'),
getStatePermissionsOfRole(state, 'Assignor'),
getStatePermissionsOfRole(state, 'Assignee'),
getStatePermissionsOfRole(state, 'Associate'),
getStatePermissionsOfRole(state, 'Author'),
getStatePermissionsOfRole(state, 'Auditor')
))
return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateUriList' )
def getStateUriList(self):
"""
"""
state_id_list = self.getStateIdList()
return map(lambda x: ('%s/states/%s' % (self.uri, x)), state_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getStateURIList' )
def getStateURIList(self):
"""
"""
state_item_list = self.getStateItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4], x[5], x[6], x[7]), state_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionIdList' )
def getTransitionIdList(self):
"""
"""
transition_list = []
for transition in self.getInstance().transitions.objectValues():
transition_list.append(transition.getId())
return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionItemList' )
def getTransitionItemList(self):
"""
"""
transition_list = []
trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod']
for transition in self.getInstance().transitions.objectValues():
guard_roles = ""
guard = dir(transition.guard)
if hasattr(transition.guard, '__dict__'):
if 'roles' in transition.guard.__dict__.keys():
guard_roles = ', '.join(role for role in transition.guard.__dict__['roles'])
transition_list.append((transition.getId(),
transition.title,
trigger_type_list[transition.trigger_type],
transition.__dict__["description"],
guard_roles
))
return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionUriList' )
def getTransitionUriList(self):
"""
"""
transition_id_list = self.getTransitionIdList()
return map(lambda x: ('%s/transitions/%s' % (self.uri, x)), transition_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionURIList' )
def getTransitionURIList(self):
"""
"""
transition_item_list = self.getTransitionItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4]), transition_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableIdList' )
def getVariableIdList(self):
"""
"""
variable_list = []
for variable in self.getInstance().variables.objectValues():
variable_list.append(variable.getId())
return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableItemList' )
def getVariableItemList(self):
"""
"""
variable_list = []
for variable in self.getInstance().variables.objectValues():
variable_list.append((variable.getId(), variable.title, variable.__dict__["description"]))
return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' )
def getVariableURIList(self):
"""
"""
variable_item_list = self.getVariableItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2]), variable_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableUriList' )
def getVariableUriList(self):
"""
"""
variable_id_list = self.getVariableIdList()
return map(lambda x: ('%s/variables/%s' % (self.uri, x)), variable_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionIdList' )
def getPermissionIdList(self):
"""
"""
permission_list = []
for permission in self.getInstance().permissions:
permission_list.append(permission)
return permission_list
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionURIList' )
def getPermissionURIList(self):
"""
"""
permission_id_list = self.getPermissionIdList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), permission_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionUriList' )
def getPermissionUriList(self):
"""
"""
permission_id_list = self.getPermissionIdList()
return map(lambda x: '%s/permissions/%s' % (self.uri, x), permission_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistIdList' )
def getWorklistIdList(self):
"""
"""
worklist_list = []
for wl in self.getInstance().worklists.objectValues():
worklist_list.append(wl.__name__)
return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistItemList' )
def getWorklistItemList(self):
"""
"""
worklist_list = []
for wl in self.getInstance().worklists.objectValues():
guard_roles = ""
guard = dir(wl.guard)
if wl.title == "":
title = wl.actbox_name
else:
title = wl.title
if hasattr(wl.guard, '__dict__'):
if 'roles' in wl.guard.__dict__.keys():
guard_roles = ', '.join(role for role in wl.guard.__dict__['roles'])
worklist_list.append((wl.__name__, title, wl.__dict__["description"],guard_roles))
return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistURIList' )
def getWorklistURIList(self):
"""
"""
worklist_item_list = self.getWorklistItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3]), worklist_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistUriList' )
def getWorklistUriList(self):
"""
"""
worklist_id_list = self.getWorklistIdList()
return map(lambda x: ('%s/worklists/%s' % (self.uri, x)), worklist_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptIdList' )
def getScriptIdList(self):
"""
"""
script_list = []
for script in self.getInstance().scripts.objectValues():
script_list.append(script.__name__)
return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptItemList' )
def getScriptItemList(self):
"""
"""
script_list = []
for script in self.getInstance().scripts.objectValues():
#guard_roles = ""
#guard = dir(script.guard)
#if hasattr(script.guard, '__dict__'):
# if 'roles' in script.guard.__dict__.keys():
# guard_roles = ', '.join(role for role in script.guard.__dict__['roles'])
script_list.append((script.__name__, script.title))
return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptURIList' )
def getScriptURIList(self):
"""
"""
script_item_list = self.getScriptItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1]), script_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptUriList' )
def getScriptUriList(self):
"""
"""
script_id_list = self.getScriptIdList()
return map(lambda x: ('%s/scripts/%s' % (self.uri, x)), script_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageURL' )
def getGraphImageURL(self):
"""
Returns a URL to a graphic representation of the workflow
"""
""
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageData' )
def getGraphImageData(self, format='png'):
"""
Returns the graphic representation of the workflow as a PNG file
"""
return getGraph(self, wf_id=self.getInstance().__name__, format=format)
InitializeClass(InteractionWorkflowDocumentationHelper)
##############################################################################
#
# 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)
##############################################################################
#
# 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,6 +30,23 @@ from Acquisition import Implicit ...@@ -30,6 +30,23 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from PortalTypeInstanceDocumentationHelper import PortalTypeInstanceDocumentationHelper
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
def getPortalType(uri=''):
"""
Extract portal type from uri to create a temporary object oh that portal_type
uri must be at the form:
portal_classes/temp_instance/Person -> a temporary instance "Person"
portal_classes/temp_instance/Person/submit -> the worfklow method "submit" of a temporary instance "Person"
"""
portal_type = ''
uri_list = uri.split('/')
if len(uri_list) >= 3:
portal_type = uri_list[3]
return portal_type
class PortalTypeDocumentationHelper(DocumentationHelper): class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
...@@ -49,7 +66,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -49,7 +66,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().getTitleOrId() return self.getDocumentedObject().Title()
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -58,6 +75,24 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -58,6 +75,24 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
return "Portal Type" return "Portal Type"
security.declareProtected( Permissions.AccessContentsInformation, 'getClass' )
def getClass(self):
"""
Returns the Class of the documentation helper
"""
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
return str(klass).split("'")[1]
security.declareProtected( Permissions.AccessContentsInformation, 'getTempInstance' )
def getTempInstance(self, portal_type=''):
"""
Returns a temporary instance of the given portal_type
"""
temp_folder = self.getPortalObject().portal_classes.newContent(id='temp_instance', portal_type='Folder', temp_object=1)
return temp_folder.newContent(id=portal_type, portal_type=portal_type, temp_object=1)
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self): def getSectionList(self):
""" """
...@@ -67,16 +102,51 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -67,16 +102,51 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
DocumentationSection( DocumentationSection(
id='action', id='action',
title='Actions', title='Actions',
class_name='ActionDocumentationHelper', class_name='PortalTypeActionDocumentationHelper',
uri_list=self.getActionURIList(), uri_list=self.getActionUriList(),
),
DocumentationSection(
id='role',
title='Role Definitions',
class_name='PortalTypeRoleDocumentationHelper',
uri_list=self.getRoleUriList(),
), ),
DocumentationSection( DocumentationSection(
id='local_role', id='allowed_content_type',
title='Local Role Definitions', title='Allowed Content Type',
class_name='LocalRoleDefinitionDocumentationHelper', class_name='PortalTypeDocumentationHelper',
uri_list=self.getDCWorkflowURIList(), uri_list=self.getAllowedContentTypeURIList(),
),
DocumentationSection(
id='hidden_content_type',
title='Hidden Content Type',
class_name='PortalTypeDocumentationHelper',
uri_list=self.getHiddenContentTypeURIList(),
),
DocumentationSection(
id='property_sheet',
title='Property Sheet',
class_name='PortalTypePropertySheetDocumentationHelper',
uri_list=self.getPropertySheetURIList(),
),
DocumentationSection(
id='workflow_method',
title='Workflow Method',
class_name='WorkflowMethodDocumentationHelper',
uri_list=self.getWorkflowMethodURIList(inherited=0),
),
DocumentationSection(
id='accessor',
title='Accessor',
class_name='AccessorMethodDocumentationHelper',
uri_list=self.getAccessorMethodURIList(inherited=0),
),
DocumentationSection(
id='class_method',
title='Class Methods',
class_name='ClassMethodDocumentationHelper',
uri_list=self.getClassMethodURIList(inherited=0),
), ),
# XXX - add here all sections of a portal type instance
]) ])
# Specific methods # Specific methods
...@@ -85,7 +155,226 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -85,7 +155,226 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
raise NotImplemented return self.getDocumentedObject().Description()
security.declareProtected( Permissions.AccessContentsInformation, 'getAllowedContentTypeList' )
def getAllowedContentTypeList(self):
"""
Returns the list of allowed content type of the documentation helper
"""
return self.getDocumentedObject().allowed_content_types
security.declareProtected( Permissions.AccessContentsInformation, 'getAllowedContentTypeURIList' )
def getAllowedContentTypeURIList(self):
"""
Returns the uri's list of allowed content type of the documentation helper
"""
allowed_content_type_list = self.getAllowedContentTypeList()
return map(lambda x: ('%s/%s' % (self.uri, x)), allowed_content_type_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getHiddenContentTypeList' )
def getHiddenContentTypeList(self):
"""
Returns the list of hidden content type of the documentation helper
"""
return self.getDocumentedObject().hidden_content_type_list
security.declareProtected( Permissions.AccessContentsInformation, 'getHiddenContentTypeURIList' )
def getHiddenContentTypeURIList(self):
"""
Returns the uri's list of hidden content type of the documentation helper
"""
hidden_content_type_list = self.getHiddenContentTypeList()
return map(lambda x: ('%s/%s' % (self.uri, x)), hidden_content_type_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getBaseCategoryList' )
def getBaseCategoryList(self):
"""
Returns the list of base category of the documentation helper
"""
return self.getDocumentedObject().base_category_list
security.declareProtected( Permissions.AccessContentsInformation, 'getAcquireLocalRoles' )
def getAcquireLocalRoles(self):
"""
Returns the list of allowed content type for the documentation helper
"""
if self.getDocumentedObject().acquire_local_roles:
return 'Yes'
else:
return 'No'
security.declareProtected( Permissions.AccessContentsInformation, 'getPropertySheetList' )
def getPropertySheetList(self):
"""
Returns the list of property sheets for the documentation helper
"""
temp_object = self.getTempInstance(self.getDocumentedObject().id)
property_sheet = []
for obj in temp_object.property_sheets:
property_sheet.append(obj.__module__.split('.')[-1])
for obj in self.getDocumentedObject().property_sheet_list:
property_sheet.append(obj)
return property_sheet
security.declareProtected( Permissions.AccessContentsInformation, 'getPropertySheetURIList' )
def getPropertySheetURIList(self):
"""
Returns the uri's list of property sheets for the documentation helper
"""
property_sheet_list = self.getPropertySheetList()
return map(lambda x: ('%s/%s.py' % (self.uri, x)), property_sheet_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getGroupList' )
def getGroupList(self):
"""
Returns the list of groups for the documentation helper
"""
return self.getDocumentedObject().group_list
security.declareProtected( Permissions.AccessContentsInformation, 'getActionIdList' )
def getActionIdList(self):
"""
"""
action_list = []
for action in self.getDocumentedObject()._actions:
action_list.append(action.getId())
return action_list
security.declareProtected( Permissions.AccessContentsInformation, 'getActionItemList' )
def getActionItemList(self):
"""
"""
action_list = []
TITLE =['No', 'Yes']
for action in self.getDocumentedObject()._actions:
permission = ', '.join(x for x in action.permissions)
visible = TITLE[action.visible]
category = action.category
action_list.append((action.getId(), action.title, action.Description(), permission, visible, category))
return action_list
security.declareProtected( Permissions.AccessContentsInformation, 'getActionURIList' )
def getActionURIList(self):
"""
"""
action_item_list = self.getActionItemList()
klass = self.getDocumentedObject().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4], x[5]), action_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getActionUriList' )
def getActionUriList(self):
"""
"""
action_id_list = self.getActionIdList()
return map(lambda x: ('%s/%s' % (self.uri, x)), action_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleIdList' )
def getRoleIdList(self):
"""
"""
role_list = []
for role in self.getDocumentedObject()._roles:
role_list.append(role.Title())
return role_list
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleItemList' )
def getRoleItemList(self):
"""
"""
role_list = []
for role in self.getDocumentedObject()._roles:
role_list.append((role.__name__, role.Title(), role.Description()))
return role_list
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleURIList' )
def getRoleURIList(self):
"""
"""
role_item_list = self.getRoleItemList()
klass = self.getDocumentedObject().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2]), role_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleUriList' )
def getRoleUriList(self):
"""
"""
role_id_list = self.getRoleIdList()
return map(lambda x: ('%s/%s' % (self.uri, x)), role_id_list)
def _getPropertyHolder(self):
from Products.ERP5Type.Base import Base
portal_type = getPortalType(self.uri)
temp_object = self.getTempInstance(portal_type)
#LOG('yomido1', INFO, 'dir() = %s' % dir(temp_object))
dir_temp = dir(temp_object)
return Base.aq_portal_type[(portal_type, temp_object.__class__)]
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' )
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()
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '' #'%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodIdList' )
def getClassMethodIdList(self, inherited=1, local=1):
"""
Return a list of tuple (id, method) for every class method
"""
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
return self._getPropertyHolder().getClassMethodIdList(klass, inherited=inherited, local=local)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodURIList' )
def getClassMethodURIList(self, inherited=1, local=1):
"""
Returns a list of URIs to class methods
"""
method_id_list = self.getClassMethodIdList(inherited=inherited, local=local)
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' )
def getAccessorMethodIdList(self, inherited=1):
"""
"""
return self._getPropertyHolder().getAccessorMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodURIList' )
def getAccessorMethodURIList(self, inherited=1, local=1):
"""
Returns a list of URIs to accessor methods
"""
method_id_list = self.getAccessorMethodIdList(inherited=inherited)
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
InitializeClass(PortalTypeDocumentationHelper) InitializeClass(PortalTypeDocumentationHelper)
...@@ -30,7 +30,8 @@ from Acquisition import Implicit ...@@ -30,7 +30,8 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
class PortalTypeInstanceDocumentationHelper(DocumentationHelper): class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
""" """
...@@ -68,12 +69,6 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper): ...@@ -68,12 +69,6 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
Returns a list of documentation sections Returns a list of documentation sections
""" """
return [ return [
#DocumentationSection(
#id='instance_property',
#title='Instance Properties',
#class_name='InstancePropertyDocumentationHelper',
#uri_list=self.getClassPropertyURIList(),
#),
DocumentationSection( DocumentationSection(
id='workflow_method', id='workflow_method',
title='Workflow Method', title='Workflow Method',
...@@ -112,7 +107,7 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper): ...@@ -112,7 +107,7 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
return self._getPropertyHolder().getAccessorMethodItemList() return self._getPropertyHolder().getAccessorMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' )
def getAccessorMethodIdList(self): def getAccessorMethodIdList(self, inherited=1):
""" """
""" """
return self._getPropertyHolder().getAccessorMethodIdList() return self._getPropertyHolder().getAccessorMethodIdList()
...@@ -122,7 +117,7 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper): ...@@ -122,7 +117,7 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
""" """
Returns a list of URIs to accessor methods 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__ klass = self.getInstance().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
...@@ -142,20 +137,21 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper): ...@@ -142,20 +137,21 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
return self._getPropertyHolder() return self._getPropertyHolder()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' )
def getWorkflowMethodIdList(self): def getWorkflowMethodIdList(self, inherited=1):
""" """
""" """
return self._getPropertyHolder().getWorkflowMethodIdList() return self._getPropertyHolder().getWorkflowMethodIdList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodURIList' )
def getWorkflowMethodURIList(self, inherited=1, local=1): def getWorkflowMethodURIList(self, inherited=1, local=1):
""" """
Returns a list of URIs to workflow methods 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__ klass = self.getInstance().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ 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) 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 ...@@ -30,6 +30,7 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class PropertyDocumentationHelper(DocumentationHelper): 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 ...@@ -30,6 +30,8 @@ from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class WorkflowMethodDocumentationHelper(DocumentationHelper): class WorkflowMethodDocumentationHelper(DocumentationHelper):
""" """
...@@ -60,6 +62,14 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper): ...@@ -60,6 +62,14 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper):
""" """
return self.getDocumentedObject().__name__ return self.getDocumentedObject().__name__
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
#security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationState' ) #security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationState' )
#def getDestinationState(self): #def getDestinationState(self):
# """ # """
...@@ -97,5 +107,4 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper): ...@@ -97,5 +107,4 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper):
""" """
return getDefinitionString(self.getDocumentedObject()) return getDefinitionString(self.getDocumentedObject())
InitializeClass(WorkflowMethodDocumentationHelper) 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 ...@@ -41,5 +41,23 @@ from InstancePropertyDocumentationHelper import InstancePropertyDocumentationHel
from PortalDocumentationHelper import PortalDocumentationHelper from PortalDocumentationHelper import PortalDocumentationHelper
from PortalTypeDocumentationHelper import PortalTypeDocumentationHelper from PortalTypeDocumentationHelper import PortalTypeDocumentationHelper
from PortalTypeInstanceDocumentationHelper import PortalTypeInstanceDocumentationHelper from PortalTypeInstanceDocumentationHelper import PortalTypeInstanceDocumentationHelper
from PortalTypeRoleDocumentationHelper import PortalTypeRoleDocumentationHelper
from PortalTypeActionDocumentationHelper import PortalTypeActionDocumentationHelper
from PortalTypePropertySheetDocumentationHelper import PortalTypePropertySheetDocumentationHelper
from PropertyDocumentationHelper import PropertyDocumentationHelper from PropertyDocumentationHelper import PropertyDocumentationHelper
from WorkflowMethodDocumentationHelper import WorkflowMethodDocumentationHelper 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