Commit 348e8bd5 authored by Mayoro Diagne's avatar Mayoro Diagne

parent 69419bf4
...@@ -78,7 +78,7 @@ class AccessorMethodDocumentationHelper(DocumentationHelper): ...@@ -78,7 +78,7 @@ class AccessorMethodDocumentationHelper(DocumentationHelper):
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self): def getDescription(self):
return self.getDocumentedObject().__doc__ return getattr(self.getDocumentedObject(), "__doc__", "")
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -86,14 +86,13 @@ class AccessorMethodDocumentationHelper(DocumentationHelper): ...@@ -86,14 +86,13 @@ class AccessorMethodDocumentationHelper(DocumentationHelper):
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Accessor Method" return "Accessor Method"
#return self.getDocumentedObject().func_code.__module__
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList') security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self): def getSectionList(self):
......
...@@ -49,7 +49,7 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -49,7 +49,7 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), 'title', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -114,21 +114,21 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -114,21 +114,21 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
""" """
Returns the description of the documentation helper Returns the description of the documentation helper
""" """
return self.getDocumentedObject().description return getattr(self.getDocumentedObject(), 'description', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getVersion' ) security.declareProtected( Permissions.AccessContentsInformation, 'getVersion' )
def getVersion(self): def getVersion(self):
""" """
Returns the version of the business template Returns the version of the business template
""" """
return self.getDocumentedObject().version return getattr(self.getDocumentedObject(), 'version', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getRevisionNumber' ) security.declareProtected( Permissions.AccessContentsInformation, 'getRevisionNumber' )
def getRevisionNumber(self): def getRevisionNumber(self):
""" """
Returns the revision number of the documentation helper Returns the revision number of the documentation helper
""" """
return self.getDocumentedObject().revision return getattr(self.getDocumentedObject(), 'revision', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getBuildingState' ) security.declareProtected( Permissions.AccessContentsInformation, 'getBuildingState' )
def getBuildingState(self): def getBuildingState(self):
...@@ -149,14 +149,15 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -149,14 +149,15 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
""" """
Returns the list of maintainers of the business template Returns the list of maintainers of the business template
""" """
return self.getDocumentedObject().maintainer return getattr(self.getDocumentedObject(), 'maintainer', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getDependencyList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getDependencyList' )
def getDependencyList(self): def getDependencyList(self):
""" """
Returns the list of dependencies of the business template Returns the list of dependencies of the business template
""" """
return self.getDocumentedObject().dependency return getattr(self.getDocumentedObject(), 'dependency', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeIdList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeIdList' )
def getPortalTypeIdList(self): def getPortalTypeIdList(self):
...@@ -191,8 +192,8 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -191,8 +192,8 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
""" """
""" """
dc_workflow_list = [] dc_workflow_list = []
#for wf in self.getDocumentedObject().template_workflow_id: template_workflow_id_list = getattr(self.getDocumentedObject(), 'template_workflow_id', [])
for wf in getattr(self.getDocumentedObject(), 'template_workflow_id', []): for wf in template_workflow_id_list:
url = '/' + self.getPortalObject().id + '/portal_workflow/' + wf url = '/' + self.getPortalObject().id + '/portal_workflow/' + wf
wf_object = self.getPortalObject().unrestrictedTraverse(url) wf_object = self.getPortalObject().unrestrictedTraverse(url)
if wf_object.__class__.__name__ == 'DCWorkflowDefinition': if wf_object.__class__.__name__ == 'DCWorkflowDefinition':
...@@ -212,7 +213,8 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -212,7 +213,8 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
""" """
""" """
workflow_list = [] workflow_list = []
for wf in getattr(self.getDocumentedObject(), 'template_workflow_id', []): template_workflow_id_list = getattr(self.getDocumentedObject(), 'template_workflow_id', [])
for wf in template_workflow_id_list:
url = '/' + self.getPortalObject().id + '/portal_workflow/' + wf url = '/' + self.getPortalObject().id + '/portal_workflow/' + wf
wf_object = self.getPortalObject().unrestrictedTraverse(url) wf_object = self.getPortalObject().unrestrictedTraverse(url)
if wf_object.__class__.__name__ == 'InteractionWorkflowDefinition': if wf_object.__class__.__name__ == 'InteractionWorkflowDefinition':
...@@ -231,9 +233,9 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -231,9 +233,9 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
def getBaseCategoryList(self): def getBaseCategoryList(self):
""" """
""" """
return getattr(self.getDocumentedObject(), 'template_base_category', []) return getattr(self.getDocumentedObject(), 'template_base_category', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getBaseCategoryURIList' )
def getBaseCategoryURIList(self): def getBaseCategoryURIList(self):
""" """
""" """
......
...@@ -54,14 +54,14 @@ class CatalogMethodDocumentationHelper(DocumentationHelper): ...@@ -54,14 +54,14 @@ class CatalogMethodDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().id return getattr(self.getDocumentedObject(), 'id', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), 'title', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getSource' ) security.declareProtected(Permissions.AccessContentsInformation, 'getSource' )
def getSource(self): def getSource(self):
...@@ -69,7 +69,7 @@ class CatalogMethodDocumentationHelper(DocumentationHelper): ...@@ -69,7 +69,7 @@ class CatalogMethodDocumentationHelper(DocumentationHelper):
Returns the source code of the documentation helper Returns the source code of the documentation helper
""" """
from zLOG import LOG, INFO from zLOG import LOG, INFO
source_code = self.getDocumentedObject().src source_code = getattr(self.getDocumentedObject(), 'src', '')
portal_transforms = getattr(self, 'portal_transforms', None) portal_transforms = getattr(self, 'portal_transforms', None)
if portal_transforms is None: if portal_transforms is None:
LOG('DCWorkflowScriptDocumentationHelper', INFO, LOG('DCWorkflowScriptDocumentationHelper', INFO,
...@@ -85,20 +85,30 @@ class CatalogMethodDocumentationHelper(DocumentationHelper): ...@@ -85,20 +85,30 @@ class CatalogMethodDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().connection_id return getattr(self.getDocumentedObject(), 'connection_id', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList' )
def getArgumentList(self): def getArgumentList(self):
""" """
Returns the arguments of the documentation helper Returns the arguments of the documentation helper
""" """
return self.getDocumentedObject()._arg._keys #return self.getDocumentedObject()._arg._keys
keys = []
arg = getattr(self.getDocumentedObject(), '_arg', None)
if arg is not None:
keys = getattr(arg, '_keys', [])
return keys
security.declareProtected(Permissions.AccessContentsInformation, 'getCatalog' ) security.declareProtected(Permissions.AccessContentsInformation, 'getCatalog' )
def getCatalog(self): def getCatalog(self):
""" """
Returns the catalog name of the documentation helper Returns the catalog name of the documentation helper
""" """
return self.getDocumentedObject().aq_parent.__name__ #return self.getDocumentedObject().aq_parent.__name__
catalog = ''
parent = getattr(self.getDocumentedObject(), 'aq_parent', None)
if parent is not None:
catalog = getattr(parent, '__name__', '')
return catalog
InitializeClass(CatalogMethodDocumentationHelper) InitializeClass(CatalogMethodDocumentationHelper)
...@@ -32,7 +32,6 @@ from Globals import InitializeClass ...@@ -32,7 +32,6 @@ from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph
def getStatePermissionsOfRole(state=None, role=''): def getStatePermissionsOfRole(state=None, role=''):
...@@ -76,7 +75,7 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -76,7 +75,7 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
Returns the Id of the documentation helper Returns the Id of the documentation helper
""" """
return self.getInstance().__name__ return getattr(self.getInstance(), '__name__', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -90,15 +89,14 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -90,15 +89,14 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getInstance().title return getattr(self.getInstance(), 'title', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' ) security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self): def getDescription(self):
""" """
Returns the description of the documentation helper Returns the description of the documentation helper
""" """
#return self.getInstance().__dict__["description"] return getattr(self.getInstance(), 'description', '')
return self.getInstance().description
...@@ -152,8 +150,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -152,8 +150,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
state_list = [] state_list = []
for state in self.getInstance().states.objectValues(): states = getattr(self.getInstance(), 'states', None)
state_list.append(state.getId()) if states is not None:
for state in states.objectValues():
state_list.append(state.getId())
return state_list return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getStateItemList' )
...@@ -161,16 +161,18 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -161,16 +161,18 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
state_list = [] state_list = []
for state in self.getInstance().states.objectValues(): states = getattr(self.getInstance(), 'states', None)
state_list.append((state.getId(), if states is not None:
state.__dict__["title"], for state in states.objectValues():
getStatePermissionsOfRole(state, 'Owner'), state_list.append((getattr(state, "id", ""),
getStatePermissionsOfRole(state, 'Assignor'), getattr(state, "title", ""),
getStatePermissionsOfRole(state, 'Assignee'), getStatePermissionsOfRole(state, 'Owner'),
getStatePermissionsOfRole(state, 'Associate'), getStatePermissionsOfRole(state, 'Assignor'),
getStatePermissionsOfRole(state, 'Author'), getStatePermissionsOfRole(state, 'Assignee'),
getStatePermissionsOfRole(state, 'Auditor') getStatePermissionsOfRole(state, 'Associate'),
)) getStatePermissionsOfRole(state, 'Author'),
getStatePermissionsOfRole(state, 'Auditor')
))
return state_list return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateUriList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getStateUriList' )
...@@ -197,8 +199,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -197,8 +199,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
transition_list = [] transition_list = []
for transition in self.getInstance().transitions.objectValues(): transitions = getattr(self.getInstance(), 'transitions', None)
transition_list.append(transition.getId()) if transitions is not None:
for transition in transitions.objectValues():
transition_list.append(transition.getId())
return transition_list return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionItemList' )
...@@ -207,18 +211,20 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -207,18 +211,20 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
transition_list = [] transition_list = []
trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod'] trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod']
for transition in self.getInstance().transitions.objectValues(): transitions = getattr(self.getInstance(), 'transitions', None)
guard_roles = "" if transitions is not None:
guard = dir(transition.guard) for transition in self.getInstance().transitions.objectValues():
if hasattr(transition.guard, '__dict__'): guard_roles = ""
if 'roles' in transition.guard.__dict__.keys(): guard = dir(transition.guard)
guard_roles = ', '.join(role for role in transition.guard.__dict__['roles']) if hasattr(transition.guard, '__dict__'):
transition_list.append((transition.getId(), if 'roles' in transition.guard.__dict__.keys():
transition.title, guard_roles = ', '.join(role for role in transition.guard.__dict__['roles'])
trigger_type_list[transition.trigger_type], transition_list.append((transition.getId(),
transition.__dict__["description"], getattr(transition, "title", ""),
guard_roles trigger_type_list[transition.trigger_type],
)) getattr(transition, "description", ""),
guard_roles
))
return transition_list return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionUriList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionUriList' )
...@@ -244,8 +250,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -244,8 +250,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
variable_list = [] variable_list = []
for variable in self.getInstance().variables.objectValues(): variables = getattr(self.getInstance(), 'variables', None)
variable_list.append(variable.getId()) if variables is not None:
for variable in variables.objectValues():
variable_list.append(variable.getId())
return variable_list return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getVariableItemList' )
...@@ -253,8 +261,13 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -253,8 +261,13 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
variable_list = [] variable_list = []
for variable in self.getInstance().variables.objectValues(): variables = getattr(self.getInstance(), 'variables', None)
variable_list.append((variable.getId(), variable.title, variable.__dict__.get("description",''))) if variables is not None:
for variable in variables.objectValues():
variable_list.append((variable.getId(),
getattr(variable, "title", ""),
getattr(variable, "description", "")
))
return variable_list return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' )
...@@ -280,8 +293,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -280,8 +293,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
permission_list = [] permission_list = []
for permission in self.getInstance().permissions: permissions = getattr(self.getInstance(), "permissions", None)
permission_list.append(permission) if permissions is not None:
for permission in permissions:
permission_list.append(permission)
return permission_list return permission_list
...@@ -308,8 +323,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -308,8 +323,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
worklist_list = [] worklist_list = []
for wl in self.getInstance().worklists.objectValues(): worklists = getattr(self.getInstance(), "worklists", None)
worklist_list.append(wl.__name__) if worklists is not None:
for wl in worklists.objectValues():
worklist_list.append(getattr(wl, "__name__", ''))
return worklist_list return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistItemList' )
...@@ -317,17 +334,19 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -317,17 +334,19 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
worklist_list = [] worklist_list = []
for wl in self.getInstance().worklists.objectValues(): worklists = getattr(self.getInstance(), "worklists", None)
guard_roles = "" if worklists is not None:
guard = dir(wl.guard) for wl in worklists.objectValues():
if wl.title == "": guard_roles = ""
title = wl.actbox_name guard = dir(wl.guard)
else: if wl.title == "":
title = wl.title title = wl.actbox_name
if hasattr(wl.guard, '__dict__'): else:
if 'roles' in wl.guard.__dict__.keys(): title = wl.title
guard_roles = ', '.join(role for role in wl.guard.__dict__['roles']) if hasattr(wl.guard, '__dict__'):
worklist_list.append((wl.__name__, title, wl.__dict__["description"],guard_roles)) 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 return worklist_list
...@@ -354,8 +373,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -354,8 +373,10 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
script_list = [] script_list = []
for script in self.getInstance().scripts.objectValues(): scripts = getattr(self.getInstance(), "scripts", None)
script_list.append(script.__name__) if scripts is not None:
for script in scripts.objectValues():
script_list.append(getattr(script, "__name__", ''))
return script_list return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getScriptItemList' )
...@@ -363,13 +384,12 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -363,13 +384,12 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
script_list = [] script_list = []
for script in self.getInstance().scripts.objectValues(): scripts = getattr(self.getInstance(), "scripts", None)
#guard_roles = "" if scripts is not None:
#guard = dir(script.guard) for script in scripts.objectValues():
#if hasattr(script.guard, '__dict__'): script_list.append((getattr(script, "__name__", ''),
# if 'roles' in script.guard.__dict__.keys(): getattr(script, "title", '')
# guard_roles = ', '.join(role for role in script.guard.__dict__['roles']) ))
script_list.append((script.__name__, script.title))
return script_list return script_list
...@@ -404,6 +424,6 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -404,6 +424,6 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
Returns the graphic representation of the workflow as a PNG file Returns the graphic representation of the workflow as a PNG file
""" """
return getGraph(self, wf_id=self.getInstance().__name__, format=format) return getGraph(self, wf_id=getattr(self.getInstance(), "__name__", ''), format=format)
InitializeClass(DCWorkflowDocumentationHelper) InitializeClass(DCWorkflowDocumentationHelper)
...@@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo ...@@ -31,7 +31,6 @@ 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 Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class DCWorkflowPermissionDocumentationHelper(DocumentationHelper): class DCWorkflowPermissionDocumentationHelper(DocumentationHelper):
""" """
...@@ -45,7 +44,7 @@ class DCWorkflowPermissionDocumentationHelper(DocumentationHelper): ...@@ -45,7 +44,7 @@ class DCWorkflowPermissionDocumentationHelper(DocumentationHelper):
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self): def getDescription(self):
return "" #self.getDocumentedObject().__dict__["description"] return getattr(self.getDocumentedObject(), "description", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -59,14 +58,14 @@ class DCWorkflowPermissionDocumentationHelper(DocumentationHelper): ...@@ -59,14 +58,14 @@ class DCWorkflowPermissionDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return "" #self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return "" #self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList') security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self): def getSectionList(self):
......
...@@ -55,7 +55,7 @@ class DCWorkflowScriptDocumentationHelper(DocumentationHelper): ...@@ -55,7 +55,7 @@ class DCWorkflowScriptDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
...@@ -63,7 +63,7 @@ class DCWorkflowScriptDocumentationHelper(DocumentationHelper): ...@@ -63,7 +63,7 @@ class DCWorkflowScriptDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList') security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self): def getSectionList(self):
......
...@@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo ...@@ -31,7 +31,6 @@ 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 Products.ERP5Type import Permissions
from zLOG import LOG, INFO
def getPermissionsOfRole(state=None, role=''): def getPermissionsOfRole(state=None, role=''):
""" """
...@@ -41,7 +40,6 @@ def getPermissionsOfRole(state=None, role=''): ...@@ -41,7 +40,6 @@ def getPermissionsOfRole(state=None, role=''):
M = Modify Portal Content M = Modify Portal Content
C = Add Portal Content C = Add Portal Content
""" """
#LOG('yoooo', INFO, 'state=%s role=%s ' % (state, role))
permissions = "" permissions = ""
if state != None: if state != None:
if hasattr(state, '__dict__'): if hasattr(state, '__dict__'):
...@@ -87,7 +85,7 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper): ...@@ -87,7 +85,7 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
...@@ -95,7 +93,7 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper): ...@@ -95,7 +93,7 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().__dict__["title"] return getattr(self.getDocumentedObject(), "title", "")
def getSectionList(self): def getSectionList(self):
""" """
...@@ -108,7 +106,7 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper): ...@@ -108,7 +106,7 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
""" """
Returns list of possible transitions from this state Returns list of possible transitions from this state
""" """
return self.getDocumentedObject().transitions return getattr(self.getDocumentedObject(), "transitions", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleOwner' ) security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleOwner' )
def getPermissionsOfRoleOwner(self): def getPermissionsOfRoleOwner(self):
......
...@@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo ...@@ -31,7 +31,6 @@ 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 Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class DCWorkflowTransitionDocumentationHelper(DocumentationHelper): class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
""" """
...@@ -45,7 +44,8 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper): ...@@ -45,7 +44,8 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self): def getDescription(self):
return self.getDocumentedObject().__dict__["description"] #return self.getDocumentedObject().__dict__["description"]
return getattr(self.getDocumentedObject(), "description", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -59,14 +59,14 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper): ...@@ -59,14 +59,14 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", "")
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self): def getSectionList(self):
...@@ -80,7 +80,7 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper): ...@@ -80,7 +80,7 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the new state for de workflow transition Returns the id of the new state for de workflow transition
""" """
return self.getDocumentedObject().new_state_id return getattr(self.getDocumentedObject(), "new_state_id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTriggerType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTriggerType' )
def getTriggerType(self): def getTriggerType(self):
...@@ -88,7 +88,7 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper): ...@@ -88,7 +88,7 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
Returns the trigger type for de workflow transition Returns the trigger type for de workflow transition
""" """
trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod'] trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod']
trigger_type_id = self.getDocumentedObject().trigger_type trigger_type_id = getattr(self.getDocumentedObject(), "trigger_type", '')
return trigger_type_list[trigger_type_id] return trigger_type_list[trigger_type_id]
security.declareProtected(Permissions.AccessContentsInformation, 'getScriptName' ) security.declareProtected(Permissions.AccessContentsInformation, 'getScriptName' )
...@@ -96,14 +96,14 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper): ...@@ -96,14 +96,14 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
""" """
Returns the name of the script for de workflow transition Returns the name of the script for de workflow transition
""" """
return self.getDocumentedObject().script_name return getattr(self.getDocumentedObject(), "script_name", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAfterScriptName' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAfterScriptName' )
def getAfterScriptName(self): def getAfterScriptName(self):
""" """
Returns the name of the script for de workflow transition Returns the name of the script for de workflow transition
""" """
return self.getDocumentedObject().after_script_name return getattr(self.getDocumentedObject(), "after_script_name", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableStateIds' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableStateIds' )
def getAvailableStateIds(self): def getAvailableStateIds(self):
...@@ -121,8 +121,6 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper): ...@@ -121,8 +121,6 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
if hasattr(self.getDocumentedObject(),'guard'): if hasattr(self.getDocumentedObject(),'guard'):
dir(self.getDocumentedObject().guard) dir(self.getDocumentedObject().guard)
if hasattr(self.getDocumentedObject().guard, '__dict__'): 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(): if 'roles' in self.getDocumentedObject().guard.__dict__.keys():
role_list = self.getDocumentedObject().guard.__dict__['roles'] role_list = self.getDocumentedObject().guard.__dict__['roles']
return ', '.join(role for role in role_list) return ', '.join(role for role in role_list)
......
...@@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo ...@@ -31,7 +31,6 @@ 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 Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class DCWorkflowVariableDocumentationHelper(DocumentationHelper): class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
""" """
...@@ -45,7 +44,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper): ...@@ -45,7 +44,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self): def getDescription(self):
return self.getDocumentedObject().__dict__["description"] return getattr(self.getDocumentedObject(), "description", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -59,7 +58,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper): ...@@ -59,7 +58,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self): def getSectionList(self):
...@@ -73,7 +72,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper): ...@@ -73,7 +72,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultExpression' ) security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultExpression' )
def getDefaultExpression(self): def getDefaultExpression(self):
...@@ -81,7 +80,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper): ...@@ -81,7 +80,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
Returns the Default Expression of the documentation helper Returns the Default Expression of the documentation helper
""" """
default_expr = "" default_expr = ""
if self.getDocumentedObject().default_expr != None: if getattr(self.getDocumentedObject(), "default_expr", None) is not None:
default_expr = self.getDocumentedObject().default_expr.text default_expr = self.getDocumentedObject().default_expr.text
return default_expr return default_expr
......
...@@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo ...@@ -31,7 +31,6 @@ 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 Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class DCWorkflowWorklistDocumentationHelper(DocumentationHelper): class DCWorkflowWorklistDocumentationHelper(DocumentationHelper):
""" """
...@@ -45,7 +44,7 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper): ...@@ -45,7 +44,7 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper):
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self): def getDescription(self):
return self.getDocumentedObject().__dict__["description"] return getattr(self.getDocumentedObject(), "description", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -59,7 +58,7 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper): ...@@ -59,7 +58,7 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self): def getSectionList(self):
......
...@@ -31,8 +31,43 @@ from AccessControl import ClassSecurityInfo ...@@ -31,8 +31,43 @@ 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 App.config import getConfiguration
from zLOG import LOG, INFO
import os import os
import random
class TempObjectLibrary(object):
"""Create temporary objets of any portal type.
The purpose of this class is to deal with the fact that a portal type may
filter content types. For each requested portal type, this class creates the
required tree of temporary objects.
All created objects are cached.
"""
def __init__(self, container):
# Folder objects doesn't filter content types.
# Objects are created in a folder when there is no other choice.
self.root = container.newContent(portal_type='Folder', temp_object=1)
self.portal_type_dict = {}
self.dependency_dict = {}
for type_info in container._getTypesTool().listTypeInfo():
for allowed in type_info.allowed_content_types:
if allowed != type_info.id:
self.dependency_dict.setdefault(allowed, []).append(type_info.id)
def __call__(self, portal_type):
"""Returns a temporary instance of the given portal_type."""
temp_object = self.portal_type_dict.get(portal_type)
if temp_object is None:
possible_parent_list = self.dependency_dict.get(portal_type)
if possible_parent_list:
# Note that the dependency graph may contain cycles,
# so we use the most simple pathfinding algorithm: random.
container = self(random.choice(possible_parent_list))
else:
container = self.root
temp_object = container.newContent(portal_type=portal_type, temp_object=1)
self.portal_type_dict[portal_type] = temp_object
return temp_object
class DocumentationHelper(Implicit): class DocumentationHelper(Implicit):
""" """
...@@ -56,12 +91,22 @@ class DocumentationHelper(Implicit): ...@@ -56,12 +91,22 @@ class DocumentationHelper(Implicit):
def __init__(self, uri): def __init__(self, uri):
self.uri = uri self.uri = uri
security.declareProtected( Permissions.AccessContentsInformation, 'getTempInstance' )
def getTempInstance(self, portal_type):
"""
Returns a temporary instance of the given portal_type
"""
self.getTempInstance = TempObjectLibrary(self.getPortalObject().portal_classes)
return self.getTempInstance(portal_type)
def getDocumentedObject(self): def getDocumentedObject(self):
if self.uri.startswith('portal_classes/temp_instance'): if self.uri.startswith('portal_classes/temp_instance'):
url, method = self.uri.split('#') url, method = self.uri.split('#')
portal_type = url.split('/')[-1] portal_type = url.split('/')[-1]
temp_folder = self.getPortalObject().portal_classes.newContent(id='temp_instance', portal_type='Folder', temp_object=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) #temp_object = temp_folder.newContent(id=portal_type, portal_type=portal_type, temp_object=1)
self.getTempInstance = TempObjectLibrary(self.getPortalObject().portal_classes)
temp_object = self.getTempInstance(portal_type)
if '/' not in method: if '/' not in method:
documented_object = getattr(temp_object, method, None) documented_object = getattr(temp_object, method, None)
else: else:
...@@ -76,11 +121,11 @@ class DocumentationHelper(Implicit): ...@@ -76,11 +121,11 @@ class DocumentationHelper(Implicit):
zope_property_sheet = instance_home + '/PropertySheet' zope_property_sheet = instance_home + '/PropertySheet'
list_propertysheets = [zope_property_sheet,] list_propertysheets = [zope_property_sheet,]
for path in list_path: for path in list_path:
full_path = instance_home+'/Products/'+path full_path = instance_home+'/Products/'+path
if os.path.isdir(full_path) and os.path.exists(full_path+'/PropertySheet'): if os.path.isdir(full_path) and os.path.exists(full_path+'/PropertySheet'):
list_propertysheets.append(full_path+'/PropertySheet') list_propertysheets.append(full_path+'/PropertySheet')
for propertysheet_directory in list_propertysheets: for propertysheet_directory in list_propertysheets:
if os.path.exists(propertysheet_directory+'/'+file_name): if os.path.exists(propertysheet_directory+'/'+file_name):
file_url = propertysheet_directory+'/'+file_name file_url = propertysheet_directory+'/'+file_name
documented_object = open(file_url) documented_object = open(file_url)
elif '/' in self.uri and '#' not in self.uri: elif '/' in self.uri and '#' not in self.uri:
...@@ -89,20 +134,20 @@ class DocumentationHelper(Implicit): ...@@ -89,20 +134,20 @@ class DocumentationHelper(Implicit):
try: try:
documented_object = self.getPortalObject().portal_categories.resolveCategory(self.uri) documented_object = self.getPortalObject().portal_categories.resolveCategory(self.uri)
except: except:
documented_object = None documented_object = None
if documented_object is None: if documented_object is None:
documented_object = self.getPortalObject().unrestrictedTraverse(self.uri) 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: if '?' in self.uri:
base_url, url = self.uri.split('?') base_url, url = self.uri.split('?')
type, name = url.split('#') type, name = url.split('#')
parent_object = self.getPortalObject().unrestrictedTraverse(base_url) parent_object = self.getPortalObject().unrestrictedTraverse(base_url)
object_list = getattr(parent_object, type, None) object_list = getattr(parent_object, type, None)
documented_object = None documented_object = None
if object_list is not None: if object_list is not None:
for obj in object_list: for obj in object_list:
if obj.__name__ == name: if obj.__name__ == name:
documented_object = obj documented_object = obj
else: else:
url, method = self.uri.split('#') url, method = self.uri.split('#')
documented_object = self.getPortalObject().unrestrictedTraverse(url) documented_object = self.getPortalObject().unrestrictedTraverse(url)
...@@ -124,10 +169,9 @@ class DocumentationHelper(Implicit): ...@@ -124,10 +169,9 @@ 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('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
......
...@@ -54,20 +54,20 @@ class ERP5FormDocumentationHelper(DocumentationHelper): ...@@ -54,20 +54,20 @@ class ERP5FormDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().id return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getEncoding' ) security.declareProtected( Permissions.AccessContentsInformation, 'getEncoding' )
def getEncoding(self): def getEncoding(self):
""" """
Returns the encoding of the ERP5 Form Returns the encoding of the ERP5 Form
""" """
return self.getDocumentedObject().encoding return getattr(self.getDocumentedObject(), "encoding", '')
InitializeClass(ERP5FormDocumentationHelper) InitializeClass(ERP5FormDocumentationHelper)
...@@ -33,7 +33,6 @@ from Globals import InitializeClass ...@@ -33,7 +33,6 @@ from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class ERP5SiteDocumentationHelper(DocumentationHelper): class ERP5SiteDocumentationHelper(DocumentationHelper):
""" """
...@@ -50,7 +49,7 @@ class ERP5SiteDocumentationHelper(DocumentationHelper): ...@@ -50,7 +49,7 @@ class ERP5SiteDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -79,7 +78,7 @@ class ERP5SiteDocumentationHelper(DocumentationHelper): ...@@ -79,7 +78,7 @@ class ERP5SiteDocumentationHelper(DocumentationHelper):
""" """
Returns the description of the documentation helper Returns the description of the documentation helper
""" """
return self.getDocumentedObject().description return getattr(self.getDocumentedObject(), "description", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateIdList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateIdList' )
def getBusinessTemplateIdList(self): def getBusinessTemplateIdList(self):
...@@ -99,18 +98,19 @@ class ERP5SiteDocumentationHelper(DocumentationHelper): ...@@ -99,18 +98,19 @@ class ERP5SiteDocumentationHelper(DocumentationHelper):
""" """
""" """
bt_list = [] bt_list = []
for bt in self.getDocumentedObject().portal_templates.objectValues(): portal_templates = getattr(self.getDocumentedObject(), "portal_templates", None)
revision = "" if portal_templates is not None:
version = "" for bt in portal_templates.objectValues():
if hasattr(bt, 'revision'): current_state = ''
revision = bt.revision for wh in bt.workflow_history['business_template_installation_workflow']:
if hasattr(bt, 'version'): current_state = wh['installation_state']
version = bt.version if current_state == 'installed':
current_state = '' bt_list.append((bt.getId(),
for wh in bt.workflow_history['business_template_installation_workflow']: getattr(bt, "title", ''),
current_state = wh['installation_state'] getattr(bt, "description", ''),
if current_state == 'installed': getattr(bt, "version", ''),
bt_list.append((bt.getId(), bt.title, bt.description, version, revision)) getattr(bt, "revision", '')
))
return bt_list return bt_list
security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateURIList' )
......
...@@ -32,7 +32,6 @@ from Globals import InitializeClass ...@@ -32,7 +32,6 @@ from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph
def getStatePermissionsOfRole(state=None, role=''): def getStatePermissionsOfRole(state=None, role=''):
...@@ -76,7 +75,8 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -76,7 +75,8 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
Returns the Id of the documentation helper Returns the Id of the documentation helper
""" """
return self.getInstance().__name__ return getattr(self.getInstance(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -90,14 +90,14 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -90,14 +90,14 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getInstance().title return getattr(self.getInstance(), "title", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' ) security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self): def getDescription(self):
""" """
Returns the description of the documentation helper Returns the description of the documentation helper
""" """
return self.getInstance().description return getattr(self.getInstance(), "description", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
...@@ -150,8 +150,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -150,8 +150,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
state_list = [] state_list = []
for state in self.getInstance().states.objectValues(): if hasattr(self.getInstance(), "states"):
state_list.append(state.getId()) if self.getInstance().states is not None:
for state in self.getInstance().states.objectValues():
state_list.append(state.getId())
return state_list return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getStateItemList' )
...@@ -159,16 +161,18 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -159,16 +161,18 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
state_list = [] state_list = []
for state in self.getInstance().states.objectValues(): if hasattr(self.getInstance(), "states"):
state_list.append((state.getId(), if self.getInstance().states is not None:
state.__dict__["title"], for state in self.getInstance().states.objectValues():
getStatePermissionsOfRole(state, 'Owner'), state_list.append((state.getId(),
getStatePermissionsOfRole(state, 'Assignor'), state.__dict__["title"],
getStatePermissionsOfRole(state, 'Assignee'), getStatePermissionsOfRole(state, 'Owner'),
getStatePermissionsOfRole(state, 'Associate'), getStatePermissionsOfRole(state, 'Assignor'),
getStatePermissionsOfRole(state, 'Author'), getStatePermissionsOfRole(state, 'Assignee'),
getStatePermissionsOfRole(state, 'Auditor') getStatePermissionsOfRole(state, 'Associate'),
)) getStatePermissionsOfRole(state, 'Author'),
getStatePermissionsOfRole(state, 'Auditor')
))
return state_list return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateUriList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getStateUriList' )
...@@ -195,8 +199,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -195,8 +199,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
transition_list = [] transition_list = []
for transition in self.getInstance().transitions.objectValues(): if hasattr(self.getInstance(), "transitions"):
transition_list.append(transition.getId()) if self.getInstance().transitions is not None:
for transition in self.getInstance().transitions.objectValues():
transition_list.append(transition.getId())
return transition_list return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionItemList' )
...@@ -205,18 +211,20 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -205,18 +211,20 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
transition_list = [] transition_list = []
trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod'] trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod']
for transition in self.getInstance().transitions.objectValues(): if hasattr(self.getInstance(), "transitions"):
guard_roles = "" if self.getInstance().transitions is not None:
guard = dir(transition.guard) for transition in self.getInstance().transitions.objectValues():
if hasattr(transition.guard, '__dict__'): guard_roles = ""
if 'roles' in transition.guard.__dict__.keys(): guard = dir(transition.guard)
guard_roles = ', '.join(role for role in transition.guard.__dict__['roles']) if hasattr(transition.guard, '__dict__'):
transition_list.append((transition.getId(), if 'roles' in transition.guard.__dict__.keys():
transition.title, guard_roles = ', '.join(role for role in transition.guard.__dict__['roles'])
trigger_type_list[transition.trigger_type], transition_list.append((transition.getId(),
transition.__dict__["description"], transition.title,
guard_roles trigger_type_list[transition.trigger_type],
)) transition.__dict__["description"],
guard_roles
))
return transition_list return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionUriList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionUriList' )
...@@ -242,8 +250,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -242,8 +250,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
variable_list = [] variable_list = []
for variable in self.getInstance().variables.objectValues(): if hasattr(self.getInstance(), "variables"):
variable_list.append(variable.getId()) if self.getInstance().variables is not None:
for variable in self.getInstance().variables.objectValues():
variable_list.append(variable.getId())
return variable_list return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getVariableItemList' )
...@@ -251,8 +261,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -251,8 +261,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
variable_list = [] variable_list = []
for variable in self.getInstance().variables.objectValues(): if hasattr(self.getInstance(), "variables"):
variable_list.append((variable.getId(), variable.title, variable.__dict__["description"])) if self.getInstance().variables is not None:
for variable in self.getInstance().variables.objectValues():
variable_list.append((variable.getId(), variable.title, variable.__dict__["description"]))
return variable_list return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' )
...@@ -278,8 +290,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -278,8 +290,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
permission_list = [] permission_list = []
for permission in self.getInstance().permissions: if hasattr(self.getInstance(), "permissions"):
permission_list.append(permission) if self.getInstance().permissions is not None:
for permission in self.getInstance().permissions:
permission_list.append(permission)
return permission_list return permission_list
...@@ -306,8 +320,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -306,8 +320,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
worklist_list = [] worklist_list = []
for wl in self.getInstance().worklists.objectValues(): if hasattr(self.getInstance(), "worklists"):
worklist_list.append(wl.__name__) if self.getInstance().worklists is not None:
for wl in self.getInstance().worklists.objectValues():
worklist_list.append(wl.__name__)
return worklist_list return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistItemList' )
...@@ -315,17 +331,19 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -315,17 +331,19 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
worklist_list = [] worklist_list = []
for wl in self.getInstance().worklists.objectValues(): if hasattr(self.getInstance(), "worklists"):
guard_roles = "" if self.getInstance().worklists is not None:
guard = dir(wl.guard) for wl in self.getInstance().worklists.objectValues():
if wl.title == "": guard_roles = ""
title = wl.actbox_name guard = dir(wl.guard)
else: if wl.title == "":
title = wl.title title = wl.actbox_name
if hasattr(wl.guard, '__dict__'): else:
if 'roles' in wl.guard.__dict__.keys(): title = wl.title
guard_roles = ', '.join(role for role in wl.guard.__dict__['roles']) if hasattr(wl.guard, '__dict__'):
worklist_list.append((wl.__name__, title, wl.__dict__["description"],guard_roles)) 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 return worklist_list
...@@ -352,8 +370,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -352,8 +370,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
script_list = [] script_list = []
for script in self.getInstance().scripts.objectValues(): if hasattr(self.getInstance(), "scripts"):
script_list.append(script.__name__) if self.getInstance().scripts is not None:
for script in self.getInstance().scripts.objectValues():
script_list.append(script.__name__)
return script_list return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getScriptItemList' )
...@@ -361,13 +381,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper): ...@@ -361,13 +381,10 @@ class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
""" """
script_list = [] script_list = []
for script in self.getInstance().scripts.objectValues(): if hasattr(self.getInstance(), "scripts"):
#guard_roles = "" if self.getInstance().scripts is not None:
#guard = dir(script.guard) for script in self.getInstance().scripts.objectValues():
#if hasattr(script.guard, '__dict__'): script_list.append((script.__name__, script.title))
# 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 return script_list
......
...@@ -54,14 +54,15 @@ class PageTemplateDocumentationHelper(DocumentationHelper): ...@@ -54,14 +54,15 @@ class PageTemplateDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().id return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' )
def getSourceCode(self): def getSourceCode(self):
...@@ -69,7 +70,7 @@ class PageTemplateDocumentationHelper(DocumentationHelper): ...@@ -69,7 +70,7 @@ class PageTemplateDocumentationHelper(DocumentationHelper):
Returns the source code the script python Returns the source code the script python
""" """
from zLOG import LOG, INFO from zLOG import LOG, INFO
source_code = self.getDocumentedObject()._text source_code = getattr(self.getDocumentedObject(), "_text", '')
portal_transforms = getattr(self, 'portal_transforms', None) portal_transforms = getattr(self, 'portal_transforms', None)
if portal_transforms is None: if portal_transforms is None:
LOG('DCWorkflowScriptDocumentationHelper', INFO, LOG('DCWorkflowScriptDocumentationHelper', INFO,
......
...@@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo ...@@ -31,7 +31,6 @@ 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 Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class PortalTypeActionDocumentationHelper(DocumentationHelper): class PortalTypeActionDocumentationHelper(DocumentationHelper):
""" """
...@@ -45,7 +44,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper): ...@@ -45,7 +44,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self): def getDescription(self):
return self.getDocumentedObject().Description() return getattr(self.getDocumentedObject(), "description", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -59,7 +58,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper): ...@@ -59,7 +58,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self): def getSectionList(self):
...@@ -73,14 +72,15 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper): ...@@ -73,14 +72,15 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissions' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPermissions' )
def getPermissions(self): def getPermissions(self):
""" """
Returns the permissions of the documentation helper Returns the permissions of the documentation helper
""" """
return ', '.join(x for x in self.getDocumentedObject().permissions) permissions = getattr(self.getDocumentedObject(), "permissions", [])
return ', '.join(x for x in permissions)
security.declareProtected(Permissions.AccessContentsInformation, 'getVisible' ) security.declareProtected(Permissions.AccessContentsInformation, 'getVisible' )
def getVisible(self): def getVisible(self):
...@@ -88,13 +88,13 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper): ...@@ -88,13 +88,13 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
Returns the visibility of the documentation helper Returns the visibility of the documentation helper
""" """
TITLE =['No', 'Yes'] TITLE =['No', 'Yes']
return TITLE[self.getDocumentedObject().visible] return TITLE[getattr(self.getDocumentedObject(), "visible", 0)]
security.declareProtected(Permissions.AccessContentsInformation, 'getCategory' ) security.declareProtected(Permissions.AccessContentsInformation, 'getCategory' )
def getCategory(self): def getCategory(self):
""" """
Returns the category of the documentation helper Returns the category of the documentation helper
""" """
return self.getDocumentedObject().category return getattr(self.getDocumentedObject(), "category", '')
InitializeClass(PortalTypeActionDocumentationHelper) InitializeClass(PortalTypeActionDocumentationHelper)
...@@ -29,11 +29,10 @@ ...@@ -29,11 +29,10 @@
from Acquisition import Implicit 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, TempObjectLibrary
from DocumentationSection import DocumentationSection from DocumentationSection import DocumentationSection
from PortalTypeInstanceDocumentationHelper import PortalTypeInstanceDocumentationHelper from PortalTypeInstanceDocumentationHelper import PortalTypeInstanceDocumentationHelper
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
def getPortalType(uri=''): def getPortalType(uri=''):
""" """
...@@ -86,12 +85,12 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -86,12 +85,12 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
security.declareProtected( Permissions.AccessContentsInformation, 'getTempInstance' ) security.declareProtected( Permissions.AccessContentsInformation, 'getTempInstance' )
def getTempInstance(self, portal_type=''): def getTempInstance(self, portal_type):
""" """
Returns a temporary instance of the given 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) self.getTempInstance = TempObjectLibrary(self.getPortalObject().portal_classes)
return temp_folder.newContent(id=portal_type, portal_type=portal_type, temp_object=1) return self.getTempInstance(portal_type)
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self): def getSectionList(self):
...@@ -133,13 +132,13 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -133,13 +132,13 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
id='workflow_method', id='workflow_method',
title='Workflow Method', title='Workflow Method',
class_name='WorkflowMethodDocumentationHelper', class_name='WorkflowMethodDocumentationHelper',
uri_list=self.getWorkflowMethodURIList(inherited=0), uri_list=self.getWorkflowMethodUriList(inherited=0),
), ),
DocumentationSection( DocumentationSection(
id='accessor', id='accessor',
title='Accessor', title='Accessor',
class_name='AccessorMethodDocumentationHelper', class_name='AccessorMethodDocumentationHelper',
uri_list=self.getAccessorMethodURIList(inherited=0), uri_list=self.getAccessorMethodUriList(inherited=0),
), ),
DocumentationSection( DocumentationSection(
id='class_method', id='class_method',
...@@ -162,7 +161,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -162,7 +161,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
Returns the list of allowed content type of the documentation helper Returns the list of allowed content type of the documentation helper
""" """
return self.getDocumentedObject().allowed_content_types return getattr(self.getDocumentedObject(), "allowed_content_types", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getAllowedContentTypeURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getAllowedContentTypeURIList' )
def getAllowedContentTypeURIList(self): def getAllowedContentTypeURIList(self):
...@@ -177,7 +176,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -177,7 +176,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
Returns the list of hidden content type of the documentation helper Returns the list of hidden content type of the documentation helper
""" """
return self.getDocumentedObject().hidden_content_type_list return getattr(self.getDocumentedObject(), "hidden_content_type_list", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getHiddenContentTypeURIList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getHiddenContentTypeURIList' )
def getHiddenContentTypeURIList(self): def getHiddenContentTypeURIList(self):
...@@ -192,14 +191,15 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -192,14 +191,15 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
Returns the list of base category of the documentation helper Returns the list of base category of the documentation helper
""" """
return self.getDocumentedObject().base_category_list return getattr(self.getDocumentedObject(), "base_category_list", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getAcquireLocalRoles' ) security.declareProtected( Permissions.AccessContentsInformation, 'getAcquireLocalRoles' )
def getAcquireLocalRoles(self): def getAcquireLocalRoles(self):
""" """
Returns the list of allowed content type for the documentation helper Returns the list of allowed content type for the documentation helper
""" """
if self.getDocumentedObject().acquire_local_roles: local_roles = getattr(self.getDocumentedObject(), "acquire_local_roles", '')
if local_roles:
return 'Yes' return 'Yes'
else: else:
return 'No' return 'No'
...@@ -209,7 +209,8 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -209,7 +209,8 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
Returns the list of property sheets for the documentation helper Returns the list of property sheets for the documentation helper
""" """
temp_object = self.getTempInstance(self.getDocumentedObject().id) id = getattr(self.getDocumentedObject(), "id", '')
temp_object = self.getTempInstance(id)
property_sheet = [] property_sheet = []
for obj in temp_object.property_sheets: for obj in temp_object.property_sheets:
property_sheet.append(obj.__module__.split('.')[-1]) property_sheet.append(obj.__module__.split('.')[-1])
...@@ -230,14 +231,15 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -230,14 +231,15 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
Returns the list of groups for the documentation helper Returns the list of groups for the documentation helper
""" """
return self.getDocumentedObject().group_list return getattr(self.getDocumentedObject(), "group_list", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getActionIdList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getActionIdList' )
def getActionIdList(self): def getActionIdList(self):
""" """
""" """
action_list = [] action_list = []
for action in self.getDocumentedObject()._actions: actions = getattr(self.getDocumentedObject(), "_actions", [])
for action in actions:
action_list.append(action.getId()) action_list.append(action.getId())
return action_list return action_list
...@@ -277,7 +279,8 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -277,7 +279,8 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
""" """
""" """
role_list = [] role_list = []
for role in self.getDocumentedObject()._roles: roles = getattr(self.getDocumentedObject(), "_roles", '')
for role in roles:
role_list.append(role.Title()) role_list.append(role.Title())
return role_list return role_list
...@@ -312,7 +315,6 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -312,7 +315,6 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
portal_type = getPortalType(self.uri) portal_type = getPortalType(self.uri)
temp_object = self.getTempInstance(portal_type) temp_object = self.getTempInstance(portal_type)
#LOG('yomido1', INFO, 'dir() = %s' % dir(temp_object))
dir_temp = dir(temp_object) dir_temp = dir(temp_object)
return Base.aq_portal_type[(portal_type, temp_object.__class__)] return Base.aq_portal_type[(portal_type, temp_object.__class__)]
...@@ -334,6 +336,20 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -334,6 +336,20 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
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)
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 = 'portal_classes/temp_instance/%s' % self.uri.split('/')[-1]
return map(lambda x: '%s#%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodIdList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodIdList' )
def getClassMethodIdList(self, inherited=1, local=1): def getClassMethodIdList(self, inherited=1, local=1):
...@@ -376,5 +392,17 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -376,5 +392,17 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
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)
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 = self.uri
return map(lambda x: '%s#%s' % (uri_prefix, x), method_id_list)
InitializeClass(PortalTypeDocumentationHelper) InitializeClass(PortalTypeDocumentationHelper)
...@@ -54,14 +54,15 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper): ...@@ -54,14 +54,15 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().name.split("/")[-1] name = getattr(self.getDocumentedObject(), "name", '')
return name.split("/")[-1]
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().name return getattr(self.etDocumentedObject(), "name", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' )
def getSourceCode(self): def getSourceCode(self):
...@@ -75,7 +76,7 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper): ...@@ -75,7 +76,7 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper):
property_sheet_file.seek(0) property_sheet_file.seek(0)
source_code = property_sheet_file.read() source_code = property_sheet_file.read()
portal_transforms = getattr(self, 'portal_transforms', None) portal_transforms = getattr(self, 'portal_transforms', None)
if portal_transforms is not None: if portal_transforms is None:
LOG('DCWorkflowScriptDocumentationHelper', INFO, LOG('DCWorkflowScriptDocumentationHelper', INFO,
'Transformation Tool is not installed. No convertion of python script to html') 'Transformation Tool is not installed. No convertion of python script to html')
return source_code return source_code
......
...@@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo ...@@ -31,7 +31,6 @@ 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 Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class PortalTypeRoleDocumentationHelper(DocumentationHelper): class PortalTypeRoleDocumentationHelper(DocumentationHelper):
""" """
...@@ -59,7 +58,7 @@ class PortalTypeRoleDocumentationHelper(DocumentationHelper): ...@@ -59,7 +58,7 @@ class PortalTypeRoleDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self): def getSectionList(self):
...@@ -73,20 +72,20 @@ class PortalTypeRoleDocumentationHelper(DocumentationHelper): ...@@ -73,20 +72,20 @@ class PortalTypeRoleDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getCategoryList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getCategoryList' )
def getCategoryList(self): def getCategoryList(self):
""" """
Returns the list of categories for the role Returns the list of categories for the role
""" """
return self.getDocumentedObject().category return getattr(self.getDocumentedObject(), "category", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryScript' ) security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryScript' )
def getBaseCategoryScript(self): def getBaseCategoryScript(self):
""" """
Returns the base category script of the role Returns the base category script of the role
""" """
return self.getDocumentedObject().base_category_script return getattr(self.getDocumentedObject(), "base_category_script", '')
InitializeClass(PortalTypeRoleDocumentationHelper) InitializeClass(PortalTypeRoleDocumentationHelper)
...@@ -54,14 +54,14 @@ class ScriptPythonDocumentationHelper(DocumentationHelper): ...@@ -54,14 +54,14 @@ class ScriptPythonDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().id return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' )
def getSourceCode(self): def getSourceCode(self):
...@@ -69,7 +69,7 @@ class ScriptPythonDocumentationHelper(DocumentationHelper): ...@@ -69,7 +69,7 @@ class ScriptPythonDocumentationHelper(DocumentationHelper):
Returns the source code the script python Returns the source code the script python
""" """
from zLOG import LOG, INFO from zLOG import LOG, INFO
source_code = self.getDocumentedObject()._body source_code = getattr(self.getDocumentedObject(), "_body", '')
portal_transforms = getattr(self, 'portal_transforms', None) portal_transforms = getattr(self, 'portal_transforms', None)
if portal_transforms is None: if portal_transforms is None:
LOG('DCWorkflowScriptDocumentationHelper', INFO, LOG('DCWorkflowScriptDocumentationHelper', INFO,
......
...@@ -42,6 +42,13 @@ class SkinFolderDocumentationHelper(DocumentationHelper): ...@@ -42,6 +42,13 @@ class SkinFolderDocumentationHelper(DocumentationHelper):
def __init__(self, uri): def __init__(self, uri):
self.uri = uri self.uri = uri
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
...@@ -54,14 +61,14 @@ class SkinFolderDocumentationHelper(DocumentationHelper): ...@@ -54,14 +61,14 @@ class SkinFolderDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().id return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getMetaTypeList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getMetaTypeList' )
def getMetaTypeList(self): def getMetaTypeList(self):
...@@ -78,9 +85,11 @@ class SkinFolderDocumentationHelper(DocumentationHelper): ...@@ -78,9 +85,11 @@ class SkinFolderDocumentationHelper(DocumentationHelper):
Returns the list of sub-objects ids of the documentation helper Returns the list of sub-objects ids of the documentation helper
""" """
file_list = [] file_list = []
for file in self.getDocumentedObject().objectValues(): files = self.getDocumentedObject()
if not meta_type or file.meta_type == meta_type: if files is not None:
file_list.append(file.id) for file in files.objectValues():
if not meta_type or file.meta_type == meta_type:
file_list.append(file.id)
return file_list return file_list
security.declareProtected(Permissions.AccessContentsInformation, 'getFileItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getFileItemList' )
...@@ -89,9 +98,11 @@ class SkinFolderDocumentationHelper(DocumentationHelper): ...@@ -89,9 +98,11 @@ class SkinFolderDocumentationHelper(DocumentationHelper):
Returns the list of sub-objects items of the documentation helper Returns the list of sub-objects items of the documentation helper
""" """
file_list = [] file_list = []
for file in self.getDocumentedObject().objectValues(): files = self.getDocumentedObject()
if not meta_type or file.meta_type == meta_type: if files is not None:
file_list.append((file.id, file.title, file.meta_type)) for file in files.objectValues():
if not meta_type or file.meta_type == meta_type:
file_list.append((file.id, file.title, file.meta_type))
return file_list return file_list
InitializeClass(SkinFolderDocumentationHelper) InitializeClass(SkinFolderDocumentationHelper)
...@@ -47,28 +47,28 @@ class SkinFolderItemDocumentationHelper(DocumentationHelper): ...@@ -47,28 +47,28 @@ class SkinFolderItemDocumentationHelper(DocumentationHelper):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return self.getDocumentedObject().meta_type return getattr(self.getDocumentedObject(), "meta_type", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self): def getId(self):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().id return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getContentType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getContentType' )
def getContentType(self): def getContentType(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().content_type return getattr(self.getDocumentedObject(), "content_type", '')
......
...@@ -45,7 +45,7 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper): ...@@ -45,7 +45,7 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper):
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self): def getDescription(self):
return self.getDocumentedObject().__doc__ return getattr(self.getDocumentedObject(), "__doc__", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
...@@ -53,14 +53,13 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper): ...@@ -53,14 +53,13 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper):
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Workflow Method" return "Workflow Method"
#return self.getDocumentedObject().__module__
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().__name__ return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self): def getSectionList(self):
......
...@@ -54,14 +54,14 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper): ...@@ -54,14 +54,14 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper):
""" """
Returns the id of the documentation helper Returns the id of the documentation helper
""" """
return self.getDocumentedObject().id return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().title return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getSource' ) security.declareProtected(Permissions.AccessContentsInformation, 'getSource' )
def getSource(self): def getSource(self):
...@@ -69,7 +69,7 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper): ...@@ -69,7 +69,7 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper):
Returns the source code of the documentation helper Returns the source code of the documentation helper
""" """
from zLOG import LOG, INFO from zLOG import LOG, INFO
source_code = self.getDocumentedObject().src source_code = getattr(self.getDocumentedObject(), "src", '')
portal_transforms = getattr(self, 'portal_transforms', None) portal_transforms = getattr(self, 'portal_transforms', None)
if portal_transforms is None: if portal_transforms is None:
LOG('DCWorkflowScriptDocumentationHelper', INFO, LOG('DCWorkflowScriptDocumentationHelper', INFO,
...@@ -85,34 +85,34 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper): ...@@ -85,34 +85,34 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return self.getDocumentedObject().connection_id return getattr(self.getDocumentedObject(), "connection_id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList' )
def getArgumentList(self): def getArgumentList(self):
""" """
Returns the arguments of the documentation helper Returns the arguments of the documentation helper
""" """
return self.getDocumentedObject().arguments_src return getattr(self.getDocumentedObject(), "arguments_src", [])
security.declareProtected(Permissions.AccessContentsInformation, 'getClassName' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassName' )
def getClassName(self): def getClassName(self):
""" """
Returns the class name of the documentation helper Returns the class name of the documentation helper
""" """
return self.getDocumentedObject().class_name_ return getattr(self.getDocumentedObject(), "class_name_", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getClassFile' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassFile' )
def getClassFile(self): def getClassFile(self):
""" """
Returns the class file of the documentation helper Returns the class file of the documentation helper
""" """
return self.getDocumentedObject().class_file_ return getattr(self.getDocumentedObject(), "class_file_", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getMaxRows' ) security.declareProtected(Permissions.AccessContentsInformation, 'getMaxRows' )
def getMaxRows(self): def getMaxRows(self):
""" """
Returns the of the documentation helper Returns the of the documentation helper
""" """
return self.getDocumentedObject().max_rows_ return getattr(self.getDocumentedObject(), "max_rows_", '')
InitializeClass(ZSQLMethodDocumentationHelper) InitializeClass(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