Commit 73af12f0 authored by Julien Muchembled's avatar Julien Muchembled

* Clean up (refactoring, code style, deletion of useless code, ...).

* Bugfixes (display of signature of callable objects, display of portal type actions, ...).
* Define list of sections in an attribute, instead of hardcoding it.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25600 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 122c9993
...@@ -26,48 +26,11 @@ ...@@ -26,48 +26,11 @@
# #
############################################################################## ##############################################################################
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, getCallableSignatureString
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
#return the definition string of an object representing a workflow method or a class method or an accessor
def getDefinitionString(obj=None):
if obj is None:
return ""
func_code = getattr(obj, "func_code", None)
if func_code is None:
return ""
fc_var_names = getattr(func_code, "co_varnames", [])
fc = []
for i in range(len(fc_var_names)):
if fc_var_names[i] == 'args':
fc.append('*args')
elif fc_var_names[i] == 'kw':
fc.append('**kw')
else:
fc.append(fc_var_names[i])
fd = obj.func_defaults
acc_def = obj.__name__ + ' ('
if fd == None:
acc_def += ', '.join(fc)
else:
for x in range(len(fc)):
if (len(fc)-(x+1)<len(fd)):
if (x == len(fc)-1):
acc_def += " "+str(fc[x])+"='"+str(fd[x-len(fd)])+"'"
else:
acc_def += " "+str(fc[x])+"='"+str(fd[x-len(fd)])+"',"
else:
if (x == len(fc)-1):
acc_def += " "+str(fc[x])
else:
acc_def += " "+str(fc[x])+","
acc_def += ")"
return acc_def
class AccessorMethodDocumentationHelper(DocumentationHelper): class AccessorMethodDocumentationHelper(DocumentationHelper):
""" """
Provides documentation about an accessor Provides documentation about an accessor
...@@ -75,54 +38,55 @@ class AccessorMethodDocumentationHelper(DocumentationHelper): ...@@ -75,54 +38,55 @@ class AccessorMethodDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
self.uri = uri def getTitle(self):
"""
"""
obj = self.getDocumentedObject()
if obj is not None:
return obj.__name__
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self): def getDescription(self):
return getattr(self.getDocumentedObject(), "__doc__", "") """
"""
obj = self.getDocumentedObject()
if obj is not None:
return obj.__doc__
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Accessor Method" return "Accessor Method"
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getArgCount')
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__name__", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self):
"""
Returns a list of documentation sections for accessors
"""
return []
security.declareProtected( Permissions.AccessContentsInformation, 'getArgCount' )
def getArgCount(self): def getArgCount(self):
""" """
Returns the number of args of the accessor Returns the number of args of the accessor
""" """
return self.getDocumentedObject().func_code.co_argcount obj = self.getDocumentedObject()
if obj is not None:
return obj.func_code.co_argcount
security.declareProtected( Permissions.AccessContentsInformation, 'getVarNames' ) security.declareProtected(Permissions.AccessContentsInformation, 'getVarNames')
def getVarNames(self): def getVarNames(self):
""" """
Returns the list of args of the accessor Returns the list of args of the accessor
""" """
return self.getDocumentedObject().func_code.co_varnames obj = self.getDocumentedObject()
if obj is not None:
return obj.func_code.co_varnames
security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' ) security.declareProtected(Permissions.AccessContentsInformation, 'getDefinition')
def getDefinition(self): def getDefinition(self):
""" """
Returns the definition of the accessor_method with the name and arguments Returns the definition of the accessor_method with the name and arguments
""" """
return getDefinitionString(self.getDocumentedObject()) obj = self.getDocumentedObject()
if obj is not None:
return getCallableSignatureString(obj)
InitializeClass(AccessorMethodDocumentationHelper) InitializeClass(AccessorMethodDocumentationHelper)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -38,32 +37,28 @@ class BaseCategoryDocumentationHelper(DocumentationHelper): ...@@ -38,32 +37,28 @@ class BaseCategoryDocumentationHelper(DocumentationHelper):
Provides access to all documentation information Provides access to all documentation information
of a portal type instance. of a portal type instance.
""" """
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): _section_list = (
self.uri = uri dict(
id='workflow_method',
def getInstance(self): title='Workflow Method',
return self.getPortalObject().restrictedTraverse(self.uri) class_name='WorkflowMethodDocumentationHelper',
),
# API Implementation dict(
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' ) id='accessor_method',
def getTitle(self): title='Accessor',
""" class_name='AccessorMethodDocumentationHelper',
Returns the title of the documentation helper ),
""" dict(
return self.getInstance().getTitleOrId() id='class_method',
title='Class Methods',
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' ) class_name='ClassMethodDocumentationHelper',
def getDescription(self): ),
""" )
Returns the title of the documentation helper
""" security.declareProtected(Permissions.AccessContentsInformation, 'getType')
return getattr(self.getInstance(), 'description', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
...@@ -75,208 +70,173 @@ class BaseCategoryDocumentationHelper(DocumentationHelper): ...@@ -75,208 +70,173 @@ class BaseCategoryDocumentationHelper(DocumentationHelper):
""" """
Returns the value of acquisition append value of the documented base category Returns the value of acquisition append value of the documented base category
""" """
return self.getInstance().getAcquisitionAppendValue() and 'True' or 'False' return self.getDocumentedObject().getAcquisitionAppendValue() and 'True' or 'False'
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionMaskValue') security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionMaskValue')
def getAcquisitionMaskValue(self): def getAcquisitionMaskValue(self):
""" """
Returns the value of acquisition mask value of the documented base category Returns the value of acquisition mask value of the documented base category
""" """
return self.getInstance().getAcquisitionMaskValue() and 'True' or 'False' return self.getDocumentedObject().getAcquisitionMaskValue() and 'True' or 'False'
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionCopyValue') security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionCopyValue')
def getAcquisitionCopyValue(self): def getAcquisitionCopyValue(self):
""" """
Returns the value of acquisition copy value of the documented base category Returns the value of acquisition copy value of the documented base category
""" """
return self.getInstance().getAcquisitionCopyValue() and 'True' or 'False' return self.getDocumentedObject().getAcquisitionCopyValue() and 'True' or 'False'
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionSyncValue') security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionSyncValue')
def getAcquisitionSyncValue(self): def getAcquisitionSyncValue(self):
""" """
Returns the value of acquisition sync value of the documented base category Returns the value of acquisition sync value of the documented base category
""" """
return self.getInstance().getAcquisitionSyncValue() and 'True' or 'False' return self.getDocumentedObject().getAcquisitionSyncValue() and 'True' or 'False'
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionBaseCategoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionBaseCategoryList')
def getAcquisitionBaseCategoryList(self): def getAcquisitionBaseCategoryList(self):
""" """
Returns the acquisition base categories of the documented base category Returns the acquisition base categories of the documented base category
""" """
return getattr(self.getInstance(), 'acquisition_base_category', []) return getattr(self.getDocumentedObject(), 'acquisition_base_category', [])
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionObjectIds') security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionObjectIds')
def getAcquisitionObjectIds(self): def getAcquisitionObjectIds(self):
""" """
Returns the acquisitions ids of the documented base category Returns the acquisitions ids of the documented base category
""" """
return getattr(self.getInstance(), 'acquisition_object_id', []) return getattr(self.getDocumentedObject(), 'acquisition_object_id', [])
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionPortalType') security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionPortalType')
def getAcquisitionPortalType(self): def getAcquisitionPortalType(self):
""" """
Returns the acquisitions ids of the documented base category Returns the acquisitions ids of the documented base category
""" """
return getattr(self.getInstance(), 'acquisition_portal_type', '') return getattr(self.getDocumentedObject(), 'acquisition_portal_type', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionCategoryType') security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionCategoryType')
def getAcquisitionCategoryType(self): def getAcquisitionCategoryType(self):
""" """
Returns the acquisitions ids of the documented base category Returns the acquisitions ids of the documented base category
""" """
return getattr(self.getInstance(), 'category_type', []) return getattr(self.getDocumentedObject(), 'category_type', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return [
DocumentationSection(
id='workflow_method',
title='Workflow Method',
class_name='WorkflowMethodDocumentationHelper',
uri_list=self.getWorkflowMethodURIList(inherited=0),
),
DocumentationSection(
id='accessor',
title='Accessor',
class_name='AccessorMethodDocumentationHelper',
uri_list=self.getAccessorMethodURIList(inherited=0),
),
DocumentationSection(
id='class_method',
title='Class Methods',
class_name='ClassMethodDocumentationHelper',
uri_list=self.getClassMethodURIList(inherited=0),
).__of__(self.getInstance()),
]
# Specific methods # Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPortalType')
def getPortalType(self): def getPortalType(self):
""" """
""" """
return self.getInstance().getPortalType() return self.getDocumentedObject().getPortalType()
def _getPropertyHolder(self):
from Products.ERP5Type.Base import Base
property_holder = None
key = (self.getPortalType(), self.getInstance().__class__)
if not(Base.aq_portal_type.has_key(key)):
self.getInstance().initializePortalTypeDynamicProperties()
property_holder = Base.aq_portal_type[(self.getPortalType(), self.getInstance().__class__)]
return property_holder
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodItemList')
def getAccessorMethodItemList(self): def getAccessorMethodItemList(self):
""" """
""" """
return self._getPropertyHolder().getAccessorMethodItemList() return self._getPropertyHolder().getAccessorMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodIdList')
def getAccessorMethodIdList(self, inherited=1): def getAccessorMethodIdList(self):
""" """
""" """
return self._getPropertyHolder().getAccessorMethodIdList() return self._getPropertyHolder().getAccessorMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodUriList')
def getAccessorMethodURIList(self, inherited=1, local=1): def getAccessorMethodUriList(self):
""" """
Returns a list of URIs to accessor methods Returns a list of URIs to accessor methods
""" """
method_id_list = self.getAccessorMethodIdList(inherited=inherited) method_id_list = self.getAccessorMethodIdList()
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name) uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list) return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodItemList')
def getWorkflowMethodItemList(self): def getWorkflowMethodItemList(self):
""" """
""" """
return self._getPropertyHolder().getWorkflowMethodItemList() return self._getPropertyHolder().getWorkflowMethodItemList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowObject' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowObject')
def getWorkflowObject(self): def getWorkflowObject(self):
""" """
""" """
return self._getPropertyHolder() return self._getPropertyHolder()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList')
def getWorkflowMethodIdList(self, inherited=1): def getWorkflowMethodIdList(self):
""" """
""" """
return self._getPropertyHolder().getWorkflowMethodIdList() return self._getPropertyHolder().getWorkflowMethodIdList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodUriList')
def getWorkflowMethodURIList(self, inherited=1, local=1): def getWorkflowMethodUriList(self):
""" """
Returns a list of URIs to workflow methods Returns a list of URIs to workflow methods
""" """
method_id_list = self.getWorkflowMethodIdList() method_id_list = self.getWorkflowMethodIdList()
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '' #'%s.%s.' % (module, class_name) uri_prefix = '' #'%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list) return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodItemList')
def getActionMethodItemList(self): def getActionMethodItemList(self):
""" """
""" """
return self._getPropertyHolder().getActionMethodItemList() return self._getPropertyHolder().getActionMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getActionMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodIdList')
def getActionMethodIdList(self): def getActionMethodIdList(self):
""" """
""" """
return self._getPropertyHolder().getActionMethodIdList() return self._getPropertyHolder().getActionMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodItemList')
def getClassMethodItemList(self, inherited=1, local=1): def getClassMethodItemList(self, **kw):
""" """
Return a list of tuple (id, method) for every class method Return a list of tuple (id, method) for every class method
""" """
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassMethodItemList(klass, inherited=inherited, local=local) return self._getPropertyHolder().getClassMethodItemList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodIdList')
def getClassMethodIdList(self, inherited=1, local=1): def getClassMethodIdList(self, **kw):
""" """
Return a list of tuple (id, method) for every class method Return a list of tuple (id, method) for every class method
""" """
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassMethodIdList(klass, inherited=inherited, local=local) return self._getPropertyHolder().getClassMethodIdList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodUriList')
def getClassMethodURIList(self, inherited=1, local=1): def getClassMethodUriList(self, inherited=0, **kw):
""" """
Returns a list of URIs to class methods Returns a list of URIs to class methods
""" """
method_id_list = self.getClassMethodIdList(inherited=inherited, local=local) method_id_list = self.getClassMethodIdList(inherited=inherited, **kw)
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name) uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list) return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassPropertyItemList')
def getClassPropertyItemList(self, inherited=1, local=1): def getClassPropertyItemList(self, **kw):
""" """
Return a list of tuple (id, method) for every class method Return a list of tuple (id, method) for every class method
""" """
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassPropertyItemList(klass, inherited=inherited, local=local) return self._getPropertyHolder().getClassPropertyItemList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassPropertyIdList')
def getClassPropertyIdList(self, inherited=1, local=1): def getClassPropertyIdList(self, **kw):
""" """
Return a list of tuple (id, method) for every class method Return a list of tuple (id, method) for every class method
""" """
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassPropertyIdList(klass, inherited=inherited, local=local) return self._getPropertyHolder().getClassPropertyIdList(klass, **kw)
InitializeClass(BaseCategoryDocumentationHelper) InitializeClass(BaseCategoryDocumentationHelper)
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,140 +38,90 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -39,140 +38,90 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
Provides access to all documentation information Provides access to all documentation information
of a business template. of a business template.
""" """
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
# API Implementation _section_list = (
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' ) dict(
def getTitle(self): id='portal_type',
""" title='Portal Types',
Returns the title of the documentation helper class_name='PortalTypeDocumentationHelper',
""" ),
return getattr(self.getDocumentedObject(), 'title', '') dict(
id='dc_workflow',
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) title='DC Workflows',
class_name='DCWorkflowDocumentationHelper',
),
dict(
id='interaction_workflow',
title='Interaction Workflows',
class_name='InteractionWorkflowDocumentationHelper',
),
dict(
id='skin_folder',
title='Skin Folders',
class_name='SkinFolderDocumentationHelper',
),
dict(
id='module',
title='Module',
class_name='PortalTypeInstanceDocumentationHelper',
),
dict(
id='catalog_method',
title='Catalog Method',
class_name='CatalogMethodDocumentationHelper',
),
dict(
id='base_category',
title='Base Category',
class_name='BaseCategoryDocumentationHelper',
),
)
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Business Template" return "Business Template"
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getVersion')
def getSectionList(self):
"""
Returns a list of documentation sections
"""
section_list = []
if self.getPortalTypeURIList() != []:
section_list.append(
DocumentationSection(
id='portal_type',
title='Portal Types',
class_name='PortalTypeDocumentationHelper',
uri_list=self.getPortalTypeURIList(),
)
)
if self.getDCWorkflowURIList() != []:
section_list.append(
DocumentationSection(
id='dc_workflow',
title='DC Workflows',
class_name='DCWorkflowDocumentationHelper',
uri_list=self.getDCWorkflowURIList(),
)
)
if self.getInteractionWorkflowURIList() != []:
section_list.append(
DocumentationSection(
id='interaction_workflow',
title='Interaction Workflows',
class_name='InteractionWorkflowDocumentationHelper',
uri_list=self.getInteractionWorkflowURIList(),
)
)
if self.getSkinFolderURIList() != []:
section_list.append(
DocumentationSection(
id='skin_folder',
title='Skin Folders',
class_name='SkinFolderDocumentationHelper',
uri_list=self.getSkinFolderURIList(),
)
)
if self.getModuleURIList() != []:
section_list.append(
DocumentationSection(
id='module',
title='Module',
class_name='PortalTypeInstanceDocumentationHelper',
uri_list=self.getModuleURIList(),
)
)
if self.getCatalogMethodURIList() != []:
section_list.append(
DocumentationSection(
id='catalog_method',
title='Catalog Method',
class_name='CatalogMethodDocumentationHelper',
uri_list=self.getCatalogMethodURIList(),
)
)
if self.getBaseCategoryURIList() != []:
section_list.append(
DocumentationSection(
id='base_category',
title='Base Category',
class_name='BaseCategoryDocumentationHelper',
uri_list=self.getBaseCategoryURIList(),
)
)
return map(lambda x: x.__of__(self), section_list)
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the description of the documentation helper
"""
return getattr(self.getDocumentedObject(), 'description', '')
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 getattr(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 getattr(self.getDocumentedObject(), 'revision', '') return getattr(self.getDocumentedObject(), 'revision', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getBuildingState' ) security.declareProtected(Permissions.AccessContentsInformation, 'getBuildingState')
def getBuildingState(self): def getBuildingState(self):
""" """
Returns the building_state of the documentation helper Returns the building_state of the documentation helper
""" """
return self.getDocumentedObject().getBuildingState() return self.getDocumentedObject().getBuildingState()
security.declareProtected( Permissions.AccessContentsInformation, 'getInstallationState' ) security.declareProtected(Permissions.AccessContentsInformation, 'getInstallationState')
def getInstallationState(self): def getInstallationState(self):
""" """
Returns the installation_state of the documentation helper Returns the installation_state of the documentation helper
""" """
return self.getDocumentedObject().getInstallationState() return self.getDocumentedObject().getInstallationState()
security.declareProtected( Permissions.AccessContentsInformation, 'getMaintainerList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getMaintainerList')
def getMaintainerList(self): def getMaintainerList(self):
""" """
Returns the list of maintainers of the business template Returns the list of maintainers of the business template
""" """
return getattr(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
...@@ -180,36 +129,36 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -180,36 +129,36 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
return getattr(self.getDocumentedObject(), 'dependency', '') return getattr(self.getDocumentedObject(), 'dependency', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPortalTypeIdList')
def getPortalTypeIdList(self): def getPortalTypeIdList(self):
""" """
""" """
return getattr(self.getDocumentedObject(), 'template_portal_type_id', []) return getattr(self.getDocumentedObject(), 'template_portal_type_id', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPortalTypeUriList')
def getPortalTypeURIList(self): def getPortalTypeUriList(self):
""" """
""" """
portal_type_list = self.getPortalTypeIdList() portal_type_list = self.getPortalTypeIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_types' base_uri = '/'+self.uri.split('/')[1]+'/portal_types'
return map(lambda x: ('%s/%s' % (base_uri, x)), portal_type_list) return map(lambda x: ('%s/%s' % (base_uri, x)), portal_type_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getSkinFolderIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getSkinFolderIdList')
def getSkinFolderIdList(self): def getSkinFolderIdList(self):
""" """
""" """
return getattr(self.getDocumentedObject(), 'template_skin_id', []) return getattr(self.getDocumentedObject(), 'template_skin_id', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getSkinFolderURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getSkinFolderUriList')
def getSkinFolderURIList(self): def getSkinFolderUriList(self):
""" """
""" """
skin_folder_list = self.getSkinFolderIdList() skin_folder_list = self.getSkinFolderIdList()
base_uri = '/' + self.getPortalObject().id + '/portal_skins' base_uri = '/' + self.getPortalObject().id + '/portal_skins'
return map(lambda x: ('%s/%s' % (base_uri, x)), skin_folder_list) return map(lambda x: ('%s/%s' % (base_uri, x)), skin_folder_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getDCWorkflowIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getDcWorkflowIdList')
def getDCWorkflowIdList(self): def getDcWorkflowIdList(self):
""" """
""" """
dc_workflow_list = [] dc_workflow_list = []
...@@ -221,15 +170,15 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -221,15 +170,15 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
dc_workflow_list.append(wf) dc_workflow_list.append(wf)
return dc_workflow_list return dc_workflow_list
security.declareProtected( Permissions.AccessContentsInformation, 'getDCWorkflowURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getDcWorkflowUriList')
def getDCWorkflowURIList(self): def getDcWorkflowUriList(self):
""" """
""" """
workflow_list = self.getDCWorkflowIdList() workflow_list = self.getDcWorkflowIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_workflow' base_uri = '/'+self.uri.split('/')[1]+'/portal_workflow'
return map(lambda x: ('%s/%s' % (base_uri, x)), workflow_list) return map(lambda x: ('%s/%s' % (base_uri, x)), workflow_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getInteractionWorkflowIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getInteractionWorkflowIdList')
def getInteractionWorkflowIdList(self): def getInteractionWorkflowIdList(self):
""" """
""" """
...@@ -242,57 +191,57 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper): ...@@ -242,57 +191,57 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
workflow_list.append(wf) workflow_list.append(wf)
return workflow_list return workflow_list
security.declareProtected( Permissions.AccessContentsInformation, 'getInteractionWorkflowURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getInteractionWorkflowUriList')
def getInteractionWorkflowURIList(self): def getInteractionWorkflowUriList(self):
""" """
""" """
workflow_list = self.getInteractionWorkflowIdList() workflow_list = self.getInteractionWorkflowIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_workflow' base_uri = '/'+self.uri.split('/')[1]+'/portal_workflow'
return map(lambda x: ('%s/%s' % (base_uri, x)), workflow_list) return map(lambda x: ('%s/%s' % (base_uri, x)), workflow_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getBaseCategoryList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryList')
def getBaseCategoryList(self): def getBaseCategoryList(self):
""" """
""" """
return getattr(self.getDocumentedObject(), 'template_base_category', '') return getattr(self.getDocumentedObject(), 'template_base_category', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getBaseCategoryURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryUriList')
def getBaseCategoryURIList(self): def getBaseCategoryUriList(self):
""" """
""" """
base_category_list = self.getBaseCategoryList() base_category_list = self.getBaseCategoryList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_categories' base_uri = '/'+self.uri.split('/')[1]+'/portal_categories'
return map(lambda x: ('%s/%s' % (base_uri, x)), base_category_list) return map(lambda x: ('%s/%s' % (base_uri, x)), base_category_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getModuleIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getModuleIdList')
def getModuleIdList(self): def getModuleIdList(self):
""" """
""" """
return getattr(self.getDocumentedObject(), 'template_module_id', []) return getattr(self.getDocumentedObject(), 'template_module_id', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getModuleURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getModuleUriList')
def getModuleURIList(self): def getModuleUriList(self):
""" """
""" """
module_list = self.getModuleIdList() module_list = self.getModuleIdList()
base_uri = '/'+self.uri.split('/')[1] base_uri = '/'+self.uri.split('/')[1]
return map(lambda x: ('%s/%s' % (base_uri, x)), module_list) return map(lambda x: ('%s/%s' % (base_uri, x)), module_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getCatalogMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getCatalogMethodIdList')
def getCatalogMethodIdList(self): def getCatalogMethodIdList(self):
""" """
""" """
return getattr(self.getDocumentedObject(), 'template_catalog_method_id', []) return getattr(self.getDocumentedObject(), 'template_catalog_method_id', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getCatalogMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getCatalogMethodUriList')
def getCatalogMethodURIList(self): def getCatalogMethodUriList(self):
""" """
""" """
catalog_method_list = self.getCatalogMethodIdList() catalog_method_list = self.getCatalogMethodIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_catalog' base_uri = '/'+self.uri.split('/')[1]+'/portal_catalog'
return map(lambda x: ('%s/%s' % (base_uri, x)), catalog_method_list) return map(lambda x: ('%s/%s' % (base_uri, x)), catalog_method_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTemplatePathList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePathList')
def getTemplatePathList(self): def getTemplatePathList(self):
""" """
""" """
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from ZSQLMethodDocumentationHelper import ZSQLMethodDocumentationHelper from ZSQLMethodDocumentationHelper import ZSQLMethodDocumentationHelper
...@@ -39,38 +38,21 @@ class CatalogMethodDocumentationHelper(ZSQLMethodDocumentationHelper): ...@@ -39,38 +38,21 @@ class CatalogMethodDocumentationHelper(ZSQLMethodDocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Catalog Method" return "Catalog Method"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getConnectionId')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), 'id', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), 'title', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getConnectionId' )
def getConnectionId(self): def getConnectionId(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return getattr(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
...@@ -82,7 +64,7 @@ class CatalogMethodDocumentationHelper(ZSQLMethodDocumentationHelper): ...@@ -82,7 +64,7 @@ class CatalogMethodDocumentationHelper(ZSQLMethodDocumentationHelper):
keys = getattr(arg, '_keys', []) keys = getattr(arg, '_keys', [])
return 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
......
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
class ClassDocumentationHelper(DocumentationHelper):
"""
"""
...@@ -26,12 +26,10 @@ ...@@ -26,12 +26,10 @@
# #
############################################################################## ##############################################################################
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, getCallableSignatureString
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class ClassMethodDocumentationHelper(DocumentationHelper): class ClassMethodDocumentationHelper(DocumentationHelper):
""" """
...@@ -40,37 +38,32 @@ class ClassMethodDocumentationHelper(DocumentationHelper): ...@@ -40,37 +38,32 @@ class ClassMethodDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getDescription(self): def getTitle(self):
return getattr(self.getDocumentedObject(), "__doc__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self):
""" """
Returns the type of the documentation helper Returns the id of the documentation helper
""" """
return "Class Method" return self.getDocumentedObject().__name__
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' ) security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getTitle(self): def getDescription(self):
""" """
Returns the type of the documentation helper
""" """
return getattr(self.getDocumentedObject(), "__doc__", '') return self.getDocumentedObject().__doc__
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList') security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getSectionList(self): def getType(self):
""" """
Returns a list of documentation sections for class method Returns the type of the documentation helper
""" """
return [] return "Class Method"
security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' ) security.declareProtected(Permissions.AccessContentsInformation, 'getDefinition')
def getDefinition(self): def getDefinition(self):
""" """
Returns the definition of the class_method with the name and arguments Returns the definition of the class_method with the name and arguments
""" """
return getDefinitionString(self.getDocumentedObject()) return getCallableSignatureString(self.getDocumentedObject())
InitializeClass(ClassMethodDocumentationHelper) InitializeClass(ClassMethodDocumentationHelper)
...@@ -26,11 +26,9 @@ ...@@ -26,11 +26,9 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph
...@@ -63,123 +61,59 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -63,123 +61,59 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): _section_list = (
self.uri = uri dict(
id='state',
def getInstance(self): title='Workflow States',
return self.getPortalObject().restrictedTraverse(self.uri) class_name='DCWorkflowStateDocumentationHelper',
),
# API Implementation dict(
security.declareProtected( Permissions.AccessContentsInformation, 'getId' ) id='transition',
def getId(self): title='Workflow Transitions',
""" class_name='DCWorkflowTransitionDocumentationHelper',
Returns the Id of the documentation helper ),
""" dict(
return getattr(self.getInstance(), '__name__', '') id='variable',
title='Workflow Variables',
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) class_name='DCWorkflowVariableDocumentationHelper',
),
dict(
id='worklist',
title='Workflow Worklists',
class_name='DCWorkflowWorklistDocumentationHelper',
),
dict(
id='script',
title='Workflow Scripts',
class_name='DCWorkflowScriptDocumentationHelper',
),
)
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "DC Workflow" return "DC Workflow"
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getInstance(), 'title', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the description of the documentation helper
"""
return getattr(self.getInstance(), 'description', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
section_list = []
if self.getStateUriList() != []:
section_list.append(
DocumentationSection(
id='state',
title='Workflow States',
class_name='DCWorkflowStateDocumentationHelper',
uri_list=self.getStateUriList(),
)
)
if self.getTransitionUriList() != []:
section_list.append(
DocumentationSection(
id='transition',
title='Workflow Transitions',
class_name='DCWorkflowTransitionDocumentationHelper',
uri_list=self.getTransitionUriList(),
)
)
if self.getVariableUriList() != []:
section_list.append(
DocumentationSection(
id='variable',
title='Workflow Variables',
class_name='DCWorkflowVariableDocumentationHelper',
uri_list=self.getVariableUriList(),
)
)
if self.getPermissionUriList() != []:
section_list.append(
DocumentationSection(
id='permission',
title='Workflow Permissions',
class_name='DCWorkflowPermissionDocumentationHelper',
uri_list=self.getPermissionUriList(),
)
)
if self.getWorklistUriList() != []:
section_list.append(
DocumentationSection(
id='worklist',
title='Workflow Worklists',
class_name='DCWorkflowWorklistDocumentationHelper',
uri_list=self.getWorklistUriList(),
)
)
if self.getScriptUriList() != []:
section_list.append(
DocumentationSection(
id='script',
title='Workflow Scripts',
class_name='DCWorkflowScriptDocumentationHelper',
uri_list=self.getScriptUriList(),
)
)
return map(lambda x: x.__of__(self), section_list)
# Specific methods # Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getStateIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getStateIdList')
def getStateIdList(self): def getStateIdList(self):
""" """
""" """
state_list = [] state_list = []
states = getattr(self.getInstance(), 'states', None) states = getattr(self.getDocumentedObject(), 'states', None)
if states is not None: if states is not None:
for state in states.objectValues(): for state in states.objectValues():
state_list.append(state.getId()) state_list.append(state.getId())
return state_list return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getStateItemList')
def getStateItemList(self): def getStateItemList(self):
""" """
""" """
state_list = [] state_list = []
states = getattr(self.getInstance(), 'states', None) states = getattr(self.getDocumentedObject(), 'states', None)
if states is not None: if states is not None:
for state in states.objectValues(): for state in states.objectValues():
state_list.append((getattr(state, "id", ""), state_list.append((getattr(state, "id", ""),
...@@ -193,7 +127,7 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -193,7 +127,7 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
)) ))
return state_list return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateUriList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getStateUriList')
def getStateUriList(self): def getStateUriList(self):
""" """
""" """
...@@ -201,37 +135,37 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -201,37 +135,37 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
return map(lambda x: ('%s/states/%s' % (self.uri, x)), state_id_list) return map(lambda x: ('%s/states/%s' % (self.uri, x)), state_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getStateURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getStateURIList')
def getStateURIList(self): def getStateURIList(self):
""" """
""" """
state_item_list = self.getStateItemList() state_item_list = self.getStateItemList()
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name) uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4], x[5], x[6], x[7]), state_item_list) return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4], x[5], x[6], x[7]), state_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionIdList')
def getTransitionIdList(self): def getTransitionIdList(self):
""" """
""" """
transition_list = [] transition_list = []
transitions = getattr(self.getInstance(), 'transitions', None) transitions = getattr(self.getDocumentedObject(), 'transitions', None)
if transitions is not None: if transitions is not None:
for transition in transitions.objectValues(): for transition in transitions.objectValues():
transition_list.append(transition.getId()) transition_list.append(transition.getId())
return transition_list return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionItemList')
def getTransitionItemList(self): def getTransitionItemList(self):
""" """
""" """
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']
transitions = getattr(self.getInstance(), 'transitions', None) transitions = getattr(self.getDocumentedObject(), 'transitions', None)
if transitions is not None: if transitions is not None:
for transition in self.getInstance().transitions.objectValues(): for transition in self.getDocumentedObject().transitions.objectValues():
guard_roles = "" guard_roles = ""
guard = dir(transition.guard) guard = dir(transition.guard)
if hasattr(transition.guard, '__dict__'): if hasattr(transition.guard, '__dict__'):
...@@ -245,41 +179,41 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -245,41 +179,41 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
)) ))
return transition_list return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionUriList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionUriList')
def getTransitionUriList(self): def getTransitionUriList(self):
""" """
""" """
transition_id_list = self.getTransitionIdList() transition_id_list = self.getTransitionIdList()
return map(lambda x: ('%s/transitions/%s' % (self.uri, x)), transition_id_list) return map(lambda x: ('%s/transitions/%s' % (self.uri, x)), transition_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionURIList')
def getTransitionURIList(self): def getTransitionURIList(self):
""" """
""" """
transition_item_list = self.getTransitionItemList() transition_item_list = self.getTransitionItemList()
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name) uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4]), transition_item_list) return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4]), transition_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getVariableIdList')
def getVariableIdList(self): def getVariableIdList(self):
""" """
""" """
variable_list = [] variable_list = []
variables = getattr(self.getInstance(), 'variables', None) variables = getattr(self.getDocumentedObject(), 'variables', None)
if variables is not None: if variables is not None:
for variable in variables.objectValues(): for variable in variables.objectValues():
variable_list.append(variable.getId()) variable_list.append(variable.getId())
return variable_list return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getVariableItemList')
def getVariableItemList(self): def getVariableItemList(self):
""" """
""" """
variable_list = [] variable_list = []
variables = getattr(self.getInstance(), 'variables', None) variables = getattr(self.getDocumentedObject(), 'variables', None)
if variables is not None: if variables is not None:
for variable in variables.objectValues(): for variable in variables.objectValues():
variable_list.append((variable.getId(), variable_list.append((variable.getId(),
...@@ -288,71 +222,47 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -288,71 +222,47 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
)) ))
return variable_list return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getVariableURIList')
def getVariableURIList(self): def getVariableURIList(self):
""" """
""" """
variable_item_list = self.getVariableItemList() variable_item_list = self.getVariableItemList()
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name) uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2]), variable_item_list) return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2]), variable_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableUriList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getVariableUriList')
def getVariableUriList(self): def getVariableUriList(self):
""" """
""" """
variable_id_list = self.getVariableIdList() variable_id_list = self.getVariableIdList()
return map(lambda x: ('%s/variables/%s' % (self.uri, x)), variable_id_list) return map(lambda x: ('%s/variables/%s' % (self.uri, x)), variable_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionList')
def getPermissionIdList(self): def getPermissionList(self):
"""
"""
permission_list = []
permissions = getattr(self.getInstance(), "permissions", None)
if permissions is not None:
for permission in permissions:
permission_list.append(permission)
return permission_list
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionURIList' )
def getPermissionURIList(self):
"""
"""
permission_id_list = self.getPermissionIdList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), permission_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionUriList' )
def getPermissionUriList(self):
""" """
""" """
permission_id_list = self.getPermissionIdList() return getattr(self.getDocumentedObject(), "permissions", ())
return map(lambda x: '%s/permissions/%s' % (self.uri, x), permission_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorklistIdList')
def getWorklistIdList(self): def getWorklistIdList(self):
""" """
""" """
worklist_list = [] worklist_list = []
worklists = getattr(self.getInstance(), "worklists", None) worklists = getattr(self.getDocumentedObject(), "worklists", None)
if worklists is not None: if worklists is not None:
for wl in worklists.objectValues(): for wl in worklists.objectValues():
worklist_list.append(getattr(wl, "__name__", '')) worklist_list.append(getattr(wl, "__name__", ''))
return worklist_list return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorklistItemList')
def getWorklistItemList(self): def getWorklistItemList(self):
""" """
""" """
worklist_list = [] worklist_list = []
worklists = getattr(self.getInstance(), "worklists", None) worklists = getattr(self.getDocumentedObject(), "worklists", None)
if worklists is not None: if worklists is not None:
for wl in worklists.objectValues(): for wl in worklists.objectValues():
guard_roles = "" guard_roles = ""
...@@ -368,41 +278,41 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -368,41 +278,41 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
return worklist_list return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorklistURIList')
def getWorklistURIList(self): def getWorklistURIList(self):
""" """
""" """
worklist_item_list = self.getWorklistItemList() worklist_item_list = self.getWorklistItemList()
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name) uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3]), worklist_item_list) return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3]), worklist_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistUriList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorklistUriList')
def getWorklistUriList(self): def getWorklistUriList(self):
""" """
""" """
worklist_id_list = self.getWorklistIdList() worklist_id_list = self.getWorklistIdList()
return map(lambda x: ('%s/worklists/%s' % (self.uri, x)), worklist_id_list) return map(lambda x: ('%s/worklists/%s' % (self.uri, x)), worklist_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getScriptIdList')
def getScriptIdList(self): def getScriptIdList(self):
""" """
""" """
script_list = [] script_list = []
scripts = getattr(self.getInstance(), "scripts", None) scripts = getattr(self.getDocumentedObject(), "scripts", None)
if scripts is not None: if scripts is not None:
for script in scripts.objectValues(): for script in scripts.objectValues():
script_list.append(getattr(script, "__name__", '')) script_list.append(getattr(script, "__name__", ''))
return script_list return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getScriptItemList')
def getScriptItemList(self): def getScriptItemList(self):
""" """
""" """
script_list = [] script_list = []
scripts = getattr(self.getInstance(), "scripts", None) scripts = getattr(self.getDocumentedObject(), "scripts", None)
if scripts is not None: if scripts is not None:
for script in scripts.objectValues(): for script in scripts.objectValues():
script_list.append((getattr(script, "__name__", ''), script_list.append((getattr(script, "__name__", ''),
...@@ -411,25 +321,25 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -411,25 +321,25 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
return script_list return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getScriptURIList')
def getScriptURIList(self): def getScriptURIList(self):
""" """
""" """
script_item_list = self.getScriptItemList() script_item_list = self.getScriptItemList()
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name) uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1]), script_item_list) return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1]), script_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptUriList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getScriptUriList')
def getScriptUriList(self): def getScriptUriList(self):
""" """
""" """
script_id_list = self.getScriptIdList() script_id_list = self.getScriptIdList()
return map(lambda x: ('%s/scripts/%s' % (self.uri, x)), script_id_list) return map(lambda x: ('%s/scripts/%s' % (self.uri, x)), script_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageURL' ) security.declareProtected(Permissions.AccessContentsInformation, 'getGraphImageURL')
def getGraphImageURL(self): def getGraphImageURL(self):
""" """
Returns a URL to a graphic representation of the workflow Returns a URL to a graphic representation of the workflow
...@@ -437,11 +347,11 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -437,11 +347,11 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
"" ""
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageData' ) security.declareProtected(Permissions.AccessContentsInformation, 'getGraphImageData')
def getGraphImageData(self, format='png'): def getGraphImageData(self, format='png'):
""" """
Returns the graphic representation of the workflow as a PNG file Returns the graphic representation of the workflow as a PNG file
""" """
return getGraph(self, wf_id=getattr(self.getInstance(), "__name__", ''), format=format) return getGraph(self, wf_id=getattr(self.getDocumentedObject(), "__name__", ''), format=format)
InitializeClass(DCWorkflowDocumentationHelper) InitializeClass(DCWorkflowDocumentationHelper)
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from zLOG import LOG, INFO
class DCWorkflowPermissionDocumentationHelper(DocumentationHelper):
"""
Provides documentation about a workflow permission
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
#return getattr(self.getDocumentedObject(), "description", "")
return ""
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow Permission"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__name__", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self):
"""
Returns a list of documentation sections for workflow permissions
"""
return []
InitializeClass(DCWorkflowPermissionDocumentationHelper)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from ScriptPythonDocumentationHelper import ScriptPythonDocumentationHelper from ScriptPythonDocumentationHelper import ScriptPythonDocumentationHelper
...@@ -36,14 +35,5 @@ class DCWorkflowScriptDocumentationHelper(ScriptPythonDocumentationHelper): ...@@ -36,14 +35,5 @@ class DCWorkflowScriptDocumentationHelper(ScriptPythonDocumentationHelper):
""" """
Provides documentation about a workflow script Provides documentation about a workflow script
""" """
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self):
"""
Returns a list of documentation sections for workflow scripts
"""
return []
InitializeClass(DCWorkflowScriptDocumentationHelper) InitializeClass(DCWorkflowScriptDocumentationHelper)
...@@ -26,39 +26,11 @@ ...@@ -26,39 +26,11 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
def getPermissionsOfRole(state=None, role=''):
"""
Returns list of permissions for a given role with AVMC format above
A = Access contents information
V = View
M = Modify Portal Content
C = Add Portal Content
"""
permissions = ""
if state != None:
if hasattr(state, '__dict__'):
if 'permission_roles' in state.__dict__.keys():
if 'View' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['View']:
permissions += "V"
if 'Access contents information' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Access contents information']:
permissions += "A"
if 'Modify portal content' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Modify portal content']:
permissions += "M"
if 'Add portal content' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Add portal content']:
permissions += "C"
return permissions
class DCWorkflowStateDocumentationHelper(DocumentationHelper): class DCWorkflowStateDocumentationHelper(DocumentationHelper):
""" """
Provides documentation about a workflow state Provides documentation about a workflow state
...@@ -66,82 +38,75 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper): ...@@ -66,82 +38,75 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return self.getDocumentedObject().__dict__["description"]
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Workflow State" return "Workflow State"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionList')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__name__", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", "")
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionList' )
def getTransitionList(self): def getTransitionList(self):
""" """
Returns list of possible transitions from this state Returns list of possible transitions from this state
""" """
return getattr(self.getDocumentedObject(), "transitions", []) return self.getDocumentedObject().transitions
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleOwner' ) def getPermissionsOfRole(self, role):
"""
Returns list of permissions for a given role with AVMC format above
A = Access contents information
V = View
M = Modify Portal Content
C = Add Portal Content
"""
permissions = ""
permission_roles = self.getDocumentedObject().permission_roles
if permission_roles:
if role in state.permission_roles.get('Access contents information', ()):
permissions += "A"
if role in state.permission_roles.get('View', ()):
permissions += "V"
if role in state.permission_roles.get('Modify portal content', ()):
permissions += "M"
if role in state.permission_roles.get('Add portal content', ()):
permissions += "C"
return permissions
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleOwner')
def getPermissionsOfRoleOwner(self): def getPermissionsOfRoleOwner(self):
""" """
""" """
return getPermissionsOfRole(self.getDocumentedObject(),'Owner') return self.getPermissionsOfRole('Owner')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssignor' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssignor')
def getPermissionsOfRoleAssignor(self): def getPermissionsOfRoleAssignor(self):
""" """
""" """
return getPermissionsOfRole(self.getDocumentedObject(),'Assignor') return self.getPermissionsOfRole('Assignor')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssignee' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssignee')
def getPermissionsOfRoleAssignee(self): def getPermissionsOfRoleAssignee(self):
""" """
""" """
return getPermissionsOfRole(self.getDocumentedObject(),'Assignee') return self.getPermissionsOfRole('Assignee')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssociate' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssociate')
def getPermissionsOfRoleAssociate(self): def getPermissionsOfRoleAssociate(self):
""" """
""" """
return getPermissionsOfRole(self.getDocumentedObject(),'Associate') return self.getPermissionsOfRole('Associate')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAuthor' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleAuthor')
def getPermissionsOfRoleAuthor(self): def getPermissionsOfRoleAuthor(self):
""" """
""" """
return getPermissionsOfRole(self.getDocumentedObject(),'Author') return self.getPermissionsOfRole('Author')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAuditor' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleAuditor')
def getPermissionsOfRoleAuditor(self): def getPermissionsOfRoleAuditor(self):
""" """
""" """
return getPermissionsOfRole(self.getDocumentedObject(),'Auditor') return self.getPermissionsOfRole('Auditor')
InitializeClass(DCWorkflowStateDocumentationHelper) InitializeClass(DCWorkflowStateDocumentationHelper)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,50 +38,21 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper): ...@@ -39,50 +38,21 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
#return self.getDocumentedObject().__dict__["description"]
return getattr(self.getDocumentedObject(), "description", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Workflow Transition" return "Workflow Transition"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getNewStateId')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__name__", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", "")
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getNewStateId' )
def getNewStateId(self): def getNewStateId(self):
""" """
Returns the id of the new state for de workflow transition Returns the id of the new state for de workflow transition
""" """
return getattr(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):
""" """
Returns the trigger type for de workflow transition Returns the trigger type for de workflow transition
...@@ -91,28 +61,28 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper): ...@@ -91,28 +61,28 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
trigger_type_id = getattr(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')
def getScriptName(self): def getScriptName(self):
""" """
Returns the name of the script for de workflow transition Returns the name of the script for de workflow transition
""" """
return getattr(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 getattr(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):
""" """
Returns available states in the workflow Returns available states in the workflow
""" """
return self.getDocumentedObject().getAvailableStateIds() return self.getDocumentedObject().getAvailableStateIds()
security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles' ) security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles')
def getGuardRoles(self): def getGuardRoles(self):
""" """
Returns roles to pass this transition Returns roles to pass this transition
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,42 +38,14 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper): ...@@ -39,42 +38,14 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return getattr(self.getDocumentedObject(), "description", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Workflow Variable" return "Workflow Variable"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultExpression')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultExpression' )
def getDefaultExpression(self): def getDefaultExpression(self):
""" """
Returns the Default Expression of the documentation helper Returns the Default Expression of the documentation helper
...@@ -84,7 +55,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper): ...@@ -84,7 +55,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
default_expr = self.getDocumentedObject().default_expr.text default_expr = self.getDocumentedObject().default_expr.text
return default_expr return default_expr
security.declareProtected(Permissions.AccessContentsInformation, 'getForCatalog' ) security.declareProtected(Permissions.AccessContentsInformation, 'getForCatalog')
def getForCatalog(self): def getForCatalog(self):
""" """
Returns 1 if variable is available in the catalog Returns 1 if variable is available in the catalog
...@@ -98,7 +69,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper): ...@@ -98,7 +69,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
else: else:
return 'No' return 'No'
security.declareProtected(Permissions.AccessContentsInformation, 'getUpdateAlways' ) security.declareProtected(Permissions.AccessContentsInformation, 'getUpdateAlways')
def getUpdateAlways(self): def getUpdateAlways(self):
""" """
Returns 1 if variable is available in the history Returns 1 if variable is available in the history
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,46 +38,22 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper): ...@@ -39,46 +38,22 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return getattr(self.getDocumentedObject(), "description", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Workflow Worklist" return "Workflow Worklist"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self): def getTitle(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
if self.getDocumentedObject().title == "": return DocumentationHelper.getTitle(self) \
return self.getDocumentedObject().actbox_name or self.getDocumentedObject().actbox_name
else:
return self.getDocumentedObject().title
security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles' ) security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles')
def getGuardRoles(self): def getGuardRoles(self):
""" """
Returns roles to pass this worklist Returns roles to pass this worklist
...@@ -91,7 +66,7 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper): ...@@ -91,7 +66,7 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper):
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)
security.declareProtected(Permissions.AccessContentsInformation, 'getVarMatches' ) security.declareProtected(Permissions.AccessContentsInformation, 'getVarMatches')
def getVarMatches(self): def getVarMatches(self):
""" """
Returns variables and values to match worklist Returns variables and values to match worklist
......
...@@ -26,13 +26,16 @@ ...@@ -26,13 +26,16 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit from Acquisition import Implicit, aq_base
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from App.config import getConfiguration from App.config import getConfiguration
import os import os
import random import random
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Utils import convertToUpperCase
from DocumentationSection import DocumentationSection
class TempObjectLibrary(object): class TempObjectLibrary(object):
...@@ -70,6 +73,27 @@ class TempObjectLibrary(object): ...@@ -70,6 +73,27 @@ class TempObjectLibrary(object):
self.portal_type_dict[portal_type] = temp_object self.portal_type_dict[portal_type] = temp_object
return temp_object return temp_object
def getCallableSignatureString(func):
"""Return the definition string of a callable object."""
from compiler.consts import CO_VARARGS, CO_VARKEYWORDS
args = list(func.func_code.co_varnames)
defaults = func.func_defaults or ()
i = func.func_code.co_argcount - len(defaults)
for default in defaults:
args[i] += '=' + repr(default)
i += 1
# XXX ERP5 code does not set co_flags attribute :(
flags = getattr(func.func_code, 'co_flags', None)
for flag, name, prefix in ((CO_VARARGS, 'args', '*'),
(CO_VARKEYWORDS, 'kw', '**')):
if flags is not None and flags & flag \
or flags is None and i < len(args) and args[i] == name:
args[i] = prefix + args[i]
i += 1
return '%s(%s)' % (func.__name__, ', '.join(args[:i]))
class DocumentationHelper(Implicit): class DocumentationHelper(Implicit):
""" """
Example URIs Example URIs
...@@ -83,16 +107,25 @@ class DocumentationHelper(Implicit): ...@@ -83,16 +107,25 @@ class DocumentationHelper(Implicit):
Products.ERP5Type.Document.Person.notify Products.ERP5Type.Document.Person.notify
Products.ERP5Type.Document.Person.isRAD Products.ERP5Type.Document.Person.isRAD
portal_types/Person portal_types/Person
portal_types/Person/actions#view portal_types/Person?_actions#view
""" """
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
_section_list = ()
# Methods to override # Methods to override
def __init__(self, uri): def __init__(self, uri):
self.uri = uri self.uri = uri
security.declareProtected( Permissions.AccessContentsInformation, 'getTempInstance' ) security.declareProtected(Permissions.AccessContentsInformation, 'getId')
def getId(self):
"""
Returns the id of the documentation helper
"""
return self.getDocumentedObject().id
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
...@@ -175,12 +208,13 @@ class DocumentationHelper(Implicit): ...@@ -175,12 +208,13 @@ class DocumentationHelper(Implicit):
#documented_object = imp.load_module(fp, pathname, description) #documented_object = imp.load_module(fp, pathname, description)
return documented_object return documented_object
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
(ex. class name) (ex. class name)
""" """
raise NotImplemented return getattr(aq_base(self.getDocumentedObject()), 'title', '')
def getType(self): def getType(self):
""" """
...@@ -189,12 +223,28 @@ class DocumentationHelper(Implicit): ...@@ -189,12 +223,28 @@ class DocumentationHelper(Implicit):
""" """
raise NotImplemented raise NotImplemented
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
"""
Returns the title of the documentation helper
"""
return getattr(aq_base(self.getDocumentedObject()), 'description', '')
def getSectionUriList(self, id, **kw):
return getattr(self, 'get%sUriList' % convertToUpperCase(id))()
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList') security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self): def getSectionList(self):
""" """
Returns a list of documentation sections Returns a list of documentation sections
""" """
return [] section_list = []
for section in self._section_list:
uri_list = self.getSectionUriList(**section)
if uri_list:
section_list.append(DocumentationSection(uri_list=uri_list, **section)
.__of__(self))
return section_list
security.declareProtected(Permissions.AccessContentsInformation, 'getURI') security.declareProtected(Permissions.AccessContentsInformation, 'getURI')
def getURI(self): def getURI(self):
...@@ -212,7 +262,7 @@ class DocumentationHelper(Implicit): ...@@ -212,7 +262,7 @@ class DocumentationHelper(Implicit):
""" """
return self.__class__.__name__ return self.__class__.__name__
security.declareProtected(Permissions.AccessContentsInformation, 'view') security.declareProtected(Permissions.View, 'view')
def view(self): def view(self):
""" """
Renders the documentation with a standard form Renders the documentation with a standard form
...@@ -220,8 +270,17 @@ class DocumentationHelper(Implicit): ...@@ -220,8 +270,17 @@ class DocumentationHelper(Implicit):
""" """
return getattr(self, '%s_view' % self.getClassName())() return getattr(self, '%s_view' % self.getClassName())()
security.declareProtected(Permissions.AccessContentsInformation, '__call__') security.declareProtected(Permissions.View, '__call__')
def __call__(self): def __call__(self):
return self.view() return self.view()
def _getPropertyHolder(self):
property_holder = None
key = self.getPortalType(), self.getDocumentedObject().__class__
if not(Base.aq_portal_type.has_key(key)):
self.getDocumentedObject().initializePortalTypeDynamicProperties()
property_holder = Base.aq_portal_type[key]
return property_holder
InitializeClass(DocumentationHelper) InitializeClass(DocumentationHelper)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,42 +38,18 @@ class ERP5FormDocumentationHelper(DocumentationHelper): ...@@ -39,42 +38,18 @@ class ERP5FormDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "ERP5 Form" return "ERP5 Form"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getEncoding')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
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 getattr(self.getDocumentedObject(), "encoding", '') return getattr(self.getDocumentedObject(), "encoding", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the description of the documentation helper
"""
return getattr(self.getDocumentedObject(), "description", '')
InitializeClass(ERP5FormDocumentationHelper) InitializeClass(ERP5FormDocumentationHelper)
...@@ -27,11 +27,9 @@ ...@@ -27,11 +27,9 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
class ERP5SiteDocumentationHelper(DocumentationHelper): class ERP5SiteDocumentationHelper(DocumentationHelper):
...@@ -39,77 +37,44 @@ class ERP5SiteDocumentationHelper(DocumentationHelper): ...@@ -39,77 +37,44 @@ class ERP5SiteDocumentationHelper(DocumentationHelper):
Provides access to all documentation information Provides access to all documentation information
of an ERP5 Site. of an ERP5 Site.
""" """
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
# API Implementation _section_list = (
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' ) dict(
def getTitle(self): id='business_template',
""" title='Business Template',
Returns the title of the documentation helper class_name='BusinessTemplateDocumentationHelper',
""" ),
return getattr(self.getDocumentedObject(), "title", '') )
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "ERP5 Site" return "ERP5 Site"
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) def getBusinessTemplateValueList(self):
def getSectionList(self): bt_list = getattr(self, 'REQUEST', {}).get("business_template_list")
""" return (bt for bt in self.getPortalObject().portal_templates.objectValues()
Returns a list of documentation sections if bt_list is None or bt.getTitle() in bt_list)
"""
return map(lambda x: x.__of__(self), [
DocumentationSection(
id='business_template',
title='Business Template',
class_name='BusinessTemplateDocumentationHelper',
uri_list=self.getBusinessTemplateUriList(),
),
])
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the description of the documentation helper
"""
return getattr(self.getDocumentedObject(), "description", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getBusinessTemplateItemList')
def getBusinessTemplateItemList(self): def getBusinessTemplateItemList(self):
""" """
""" """
REQUEST = getattr(self, 'REQUEST', None)
business_template_list = [bt.getTitle() for bt in self.getDocumentedObject().portal_templates.objectValues()]
if REQUEST is not None and "business_template_list" in REQUEST.keys():
business_template_list = REQUEST.get("business_template_list", [])
return [(bt.getId(), return [(bt.getId(),
getattr(bt, "title", ''), getattr(bt, "title", ''),
getattr(bt, "description", ''), getattr(bt, "description", ''),
getattr(bt, "version", ''), getattr(bt, "version", ''),
getattr(bt, "revision", '')) getattr(bt, "revision", ''))
for bt in self.getDocumentedObject().portal_templates.objectValues() for bt in self.getBusinessTemplateValueList()]
if bt.getInstallationState() == 'installed' and bt.getTitle() in business_template_list]
security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateURIList' )
def getBusinessTemplateURIList(self):
"""
"""
bt_list = self.getBusinessTemplateItemList()
base_uri = '/'+self.uri.split('/')[1]
return map(lambda x: ('%s/portal_templates/%s' % (base_uri, x[0]),x[1], x[2], x[3], x[4]), bt_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateUriList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getBusinessTemplateUriList')
def getBusinessTemplateUriList(self): def getBusinessTemplateUriList(self):
""" """
""" """
bt_list = self.getBusinessTemplateItemList() return [bt.getPath() for bt in self.getBusinessTemplateValueList()]
base_uri = '/'+self.uri.split('/')[1]
return map(lambda x: ('%s/portal_templates/%s' % (base_uri, x[0])), bt_list)
InitializeClass(ERP5SiteDocumentationHelper) InitializeClass(ERP5SiteDocumentationHelper)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
......
...@@ -26,399 +26,28 @@ ...@@ -26,399 +26,28 @@
# #
############################################################################## ##############################################################################
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 DCWorkflowStateDocumentationHelper import DCWorkflowStateDocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph
def getStatePermissionsOfRole(state=None, role=''): # XXX To be implemented. For the moment,
permissions = "" # make it a subclass of DCWorkflowStateDocumentationHelper.
if state != None:
if hasattr(state, '__dict__'):
if 'permission_roles' in state.__dict__.keys():
if 'View' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['View']:
permissions += "V"
if 'Access contents information' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Access contents information']:
permissions += "A"
if 'Modify portal content' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Modify portal content']:
permissions += "M"
if 'Add portal content' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Add portal content']:
permissions += "C"
return permissions
class InteractionWorkflowDocumentationHelper(DCWorkflowStateDocumentationHelper):
class InteractionWorkflowDocumentationHelper(DocumentationHelper):
""" """
Provides access to all documentation information Provides access to all documentation information
of an interaction workflow. of an interaction workflow.
""" """
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
def getInstance(self):
return self.getPortalObject().restrictedTraverse(self.uri)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the Id of the documentation helper
"""
return getattr(self.getInstance(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Interaction Workflow" return "Interaction Workflow"
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getInstance(), "title", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the description of the documentation helper
"""
return getattr(self.getInstance(), "description", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return map(lambda x: x.__of__(self), [
DocumentationSection(
id='state',
title='Workflow States',
class_name='DCWorkflowStateDocumentationHelper',
uri_list=self.getStateUriList(),
),
DocumentationSection(
id='transition',
title='Workflow Transitions',
class_name='DCWorkflowTransitionDocumentationHelper',
uri_list=self.getTransitionUriList(),
),
DocumentationSection(
id='variable',
title='Workflow Variables',
class_name='DCWorkflowVariableDocumentationHelper',
uri_list=self.getVariableUriList(),
),
DocumentationSection(
id='permission',
title='Workflow Permissions',
class_name='DCWorkflowPermissionDocumentationHelper',
uri_list=self.getPermissionUriList(),
),
DocumentationSection(
id='worklist',
title='Workflow Worklists',
class_name='DCWorkflowWorklistDocumentationHelper',
uri_list=self.getWorklistUriList(),
),
DocumentationSection(
id='script',
title='Workflow Scripts',
class_name='DCWorkflowScriptDocumentationHelper',
uri_list=self.getScriptUriList(),
),
])
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getStateIdList' )
def getStateIdList(self):
"""
"""
state_list = []
if hasattr(self.getInstance(), "states"):
if self.getInstance().states is not None:
for state in self.getInstance().states.objectValues():
state_list.append(state.getId())
return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateItemList' )
def getStateItemList(self):
"""
"""
state_list = []
if hasattr(self.getInstance(), "states"):
if self.getInstance().states is not None:
for state in self.getInstance().states.objectValues():
state_list.append((state.getId(),
state.__dict__["title"],
getStatePermissionsOfRole(state, 'Owner'),
getStatePermissionsOfRole(state, 'Assignor'),
getStatePermissionsOfRole(state, 'Assignee'),
getStatePermissionsOfRole(state, 'Associate'),
getStatePermissionsOfRole(state, 'Author'),
getStatePermissionsOfRole(state, 'Auditor')
))
return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateUriList' )
def getStateUriList(self):
"""
"""
state_id_list = self.getStateIdList()
return map(lambda x: ('%s/states/%s' % (self.uri, x)), state_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getStateURIList' )
def getStateURIList(self):
"""
"""
state_item_list = self.getStateItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4], x[5], x[6], x[7]), state_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionIdList' )
def getTransitionIdList(self):
"""
"""
transition_list = []
if hasattr(self.getInstance(), "transitions"):
if self.getInstance().transitions is not None:
for transition in self.getInstance().transitions.objectValues():
transition_list.append(transition.getId())
return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionItemList' )
def getTransitionItemList(self):
"""
"""
transition_list = []
trigger_type_list = ['Automatic','Initiated by user action','Initiated by WorkflowMethod']
if hasattr(self.getInstance(), "transitions"):
if self.getInstance().transitions is not None:
for transition in self.getInstance().transitions.objectValues():
guard_roles = ""
guard = dir(transition.guard)
if hasattr(transition.guard, '__dict__'):
if 'roles' in transition.guard.__dict__.keys():
guard_roles = ', '.join(role for role in transition.guard.__dict__['roles'])
transition_list.append((transition.getId(),
transition.title,
trigger_type_list[transition.trigger_type],
transition.__dict__["description"],
guard_roles
))
return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionUriList' )
def getTransitionUriList(self):
"""
"""
transition_id_list = self.getTransitionIdList()
return map(lambda x: ('%s/transitions/%s' % (self.uri, x)), transition_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionURIList' )
def getTransitionURIList(self):
"""
"""
transition_item_list = self.getTransitionItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4]), transition_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableIdList' )
def getVariableIdList(self):
"""
"""
variable_list = []
if hasattr(self.getInstance(), "variables"):
if self.getInstance().variables is not None:
for variable in self.getInstance().variables.objectValues():
variable_list.append(variable.getId())
return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableItemList' )
def getVariableItemList(self):
"""
"""
variable_list = []
if hasattr(self.getInstance(), "variables"):
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
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' )
def getVariableURIList(self):
"""
"""
variable_item_list = self.getVariableItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2]), variable_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableUriList' )
def getVariableUriList(self):
"""
"""
variable_id_list = self.getVariableIdList()
return map(lambda x: ('%s/variables/%s' % (self.uri, x)), variable_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionIdList' )
def getPermissionIdList(self):
"""
"""
permission_list = []
if hasattr(self.getInstance(), "permissions"):
if self.getInstance().permissions is not None:
for permission in self.getInstance().permissions:
permission_list.append(permission)
return permission_list
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionURIList' )
def getPermissionURIList(self):
"""
"""
permission_id_list = self.getPermissionIdList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), permission_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionUriList' )
def getPermissionUriList(self):
"""
"""
permission_id_list = self.getPermissionIdList()
return map(lambda x: '%s/permissions/%s' % (self.uri, x), permission_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistIdList' )
def getWorklistIdList(self):
"""
"""
worklist_list = []
if hasattr(self.getInstance(), "worklists"):
if self.getInstance().worklists is not None:
for wl in self.getInstance().worklists.objectValues():
worklist_list.append(wl.__name__)
return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistItemList' )
def getWorklistItemList(self):
"""
"""
worklist_list = []
if hasattr(self.getInstance(), "worklists"):
if self.getInstance().worklists is not None:
for wl in self.getInstance().worklists.objectValues():
guard_roles = ""
guard = dir(wl.guard)
if wl.title == "":
title = wl.actbox_name
else:
title = wl.title
if hasattr(wl.guard, '__dict__'):
if 'roles' in wl.guard.__dict__.keys():
guard_roles = ', '.join(role for role in wl.guard.__dict__['roles'])
worklist_list.append((wl.__name__, title, wl.__dict__["description"],guard_roles))
return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistURIList' )
def getWorklistURIList(self):
"""
"""
worklist_item_list = self.getWorklistItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3]), worklist_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistUriList' )
def getWorklistUriList(self):
"""
"""
worklist_id_list = self.getWorklistIdList()
return map(lambda x: ('%s/worklists/%s' % (self.uri, x)), worklist_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptIdList' )
def getScriptIdList(self):
"""
"""
script_list = []
if hasattr(self.getInstance(), "scripts"):
if self.getInstance().scripts is not None:
for script in self.getInstance().scripts.objectValues():
script_list.append(script.__name__)
return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptItemList' )
def getScriptItemList(self):
"""
"""
script_list = []
if hasattr(self.getInstance(), "scripts"):
if self.getInstance().scripts is not None:
for script in self.getInstance().scripts.objectValues():
script_list.append((script.__name__, script.title))
return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptURIList' )
def getScriptURIList(self):
"""
"""
script_item_list = self.getScriptItemList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1]), script_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptUriList' )
def getScriptUriList(self):
"""
"""
script_id_list = self.getScriptIdList()
return map(lambda x: ('%s/scripts/%s' % (self.uri, x)), script_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageURL' )
def getGraphImageURL(self):
"""
Returns a URL to a graphic representation of the workflow
"""
""
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageData' )
def getGraphImageData(self, format='png'):
"""
Returns the graphic representation of the workflow as a PNG file
"""
return getGraph(self, wf_id=self.getInstance().__name__, format=format)
InitializeClass(InteractionWorkflowDocumentationHelper) InitializeClass(InteractionWorkflowDocumentationHelper)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,40 +38,14 @@ class PageTemplateDocumentationHelper(DocumentationHelper): ...@@ -39,40 +38,14 @@ class PageTemplateDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Page Template" return "Page Template"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getSourceCode')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the description of the documentation helper
"""
return getattr(self.getDocumentedObject(), "description", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' )
def getSourceCode(self): def getSourceCode(self):
""" """
Returns the source code the script python Returns the source code the script python
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,45 +38,14 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper): ...@@ -39,45 +38,14 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Portal Type Action" return "Portal Type Action"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPermissions')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "description", '')
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
...@@ -85,7 +53,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper): ...@@ -85,7 +53,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
permissions = getattr(self.getDocumentedObject(), "permissions", []) permissions = getattr(self.getDocumentedObject(), "permissions", [])
return ', '.join(x for x in permissions) return ', '.join(x for x in permissions)
security.declareProtected(Permissions.AccessContentsInformation, 'getVisible' ) security.declareProtected(Permissions.AccessContentsInformation, 'getVisible')
def getVisible(self): def getVisible(self):
""" """
Returns the visibility of the documentation helper Returns the visibility of the documentation helper
...@@ -93,7 +61,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper): ...@@ -93,7 +61,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
TITLE =['No', 'Yes'] TITLE =['No', 'Yes']
return TITLE[getattr(self.getDocumentedObject(), "visible", 0)] 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
......
...@@ -26,13 +26,13 @@ ...@@ -26,13 +26,13 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from Products.ERP5Type import Permissions
from Products.ERP5Type.Base import Base
from DocumentationHelper import DocumentationHelper, TempObjectLibrary 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
def getPortalType(uri=''): def getPortalType(uri=''):
""" """
...@@ -59,22 +59,64 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -59,22 +59,64 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
# API Implementation _section_list = (
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' ) dict(
def getTitle(self): id='action',
""" title='Actions',
Returns the title of the documentation helper class_name='PortalTypeActionDocumentationHelper',
""" ),
return self.getDocumentedObject().Title() dict(
id='role',
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) title='Role Definitions',
class_name='PortalTypeRoleDocumentationHelper',
),
dict(
id='allowed_content_type',
title='Allowed Content Type',
class_name='PortalTypeDocumentationHelper',
),
dict(
id='hidden_content_type',
title='Hidden Content Type',
class_name='PortalTypeDocumentationHelper',
),
dict(
id='property_sheet',
title='Property Sheet',
class_name='PortalTypePropertySheetDocumentationHelper',
),
dict(
id='workflow_method',
title='Workflow Method',
class_name='WorkflowMethodDocumentationHelper',
),
dict(
id='accessor_method',
title='Accessor',
class_name='AccessorMethodDocumentationHelper',
),
dict(
id='class_method',
title='Class Methods',
class_name='ClassMethodDocumentationHelper',
),
)
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Portal Type" return "Portal Type"
security.declareProtected( Permissions.AccessContentsInformation, 'getClass' ) security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return DocumentationHelper.getTitle(self) or self.getId()
security.declareProtected(Permissions.AccessContentsInformation, 'getClass')
def getClass(self): def getClass(self):
""" """
Returns the Class of the documentation helper Returns the Class of the documentation helper
...@@ -83,150 +125,44 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -83,150 +125,44 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
klass = self.getTempInstance(portal_type).__class__.__bases__[0] klass = self.getTempInstance(portal_type).__class__.__bases__[0]
return str(klass).split("'")[1] return str(klass).split("'")[1]
security.declareProtected(Permissions.AccessContentsInformation, 'getAllowedContentTypeList')
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)
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
section_list = []
if self.getActionUriList() != []:
section_list.append(
DocumentationSection(
id='action',
title='Actions',
class_name='PortalTypeActionDocumentationHelper',
uri_list=self.getActionUriList(),
)
)
if self.getRoleUriList() != []:
section_list.append(
DocumentationSection(
id='role',
title='Role Definitions',
class_name='PortalTypeRoleDocumentationHelper',
uri_list=self.getRoleUriList(),
)
)
if self.getRoleUriList() != []:
section_list.append(
DocumentationSection(
id='role',
title='Role Definitions',
class_name='PortalTypeRoleDocumentationHelper',
uri_list=self.getRoleUriList(),
)
)
if self.getAllowedContentTypeURIList() != []:
section_list.append(
DocumentationSection(
id='allowed_content_type',
title='Allowed Content Type',
class_name='PortalTypeDocumentationHelper',
uri_list=self.getAllowedContentTypeURIList(),
)
)
if self.getHiddenContentTypeURIList() != []:
section_list.append(
DocumentationSection(
id='hidden_content_type',
title='Hidden Content Type',
class_name='PortalTypeDocumentationHelper',
uri_list=self.getHiddenContentTypeURIList(),
)
)
if self.getPropertySheetURIList() != []:
section_list.append(
DocumentationSection(
id='property_sheet',
title='Property Sheet',
class_name='PortalTypePropertySheetDocumentationHelper',
uri_list=self.getPropertySheetURIList(),
)
)
if self.getWorkflowMethodUriList(inherited=0) != []:
section_list.append(
DocumentationSection(
id='workflow_method',
title='Workflow Method',
class_name='WorkflowMethodDocumentationHelper',
uri_list=self.getWorkflowMethodUriList(inherited=0),
)
)
if self.getAccessorMethodUriList(inherited=0) != []:
section_list.append(
DocumentationSection(
id='accessor',
title='Accessor',
class_name='AccessorMethodDocumentationHelper',
uri_list=self.getAccessorMethodUriList(inherited=0),
)
)
if self.getClassMethodURIList(inherited=0) != []:
section_list.append(
DocumentationSection(
id='class_method',
title='Class Methods',
class_name='ClassMethodDocumentationHelper',
uri_list=self.getClassMethodURIList(inherited=0),
)
)
return map(lambda x: x.__of__(self), section_list)
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().Description()
security.declareProtected( Permissions.AccessContentsInformation, 'getAllowedContentTypeList' )
def getAllowedContentTypeList(self): def getAllowedContentTypeList(self):
""" """
Returns the list of allowed content type of the documentation helper Returns the list of allowed content type of the documentation helper
""" """
return getattr(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):
""" """
Returns the uri's list of allowed content type of the documentation helper Returns the uri's list of allowed content type of the documentation helper
""" """
allowed_content_type_list = self.getAllowedContentTypeList() allowed_content_type_list = self.getAllowedContentTypeList()
return map(lambda x: ('%s/%s' % (self.uri, x)), allowed_content_type_list) return map(lambda x: ('%s/%s' % (self.uri, x)), allowed_content_type_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getHiddenContentTypeList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getHiddenContentTypeList')
def getHiddenContentTypeList(self): def getHiddenContentTypeList(self):
""" """
Returns the list of hidden content type of the documentation helper Returns the list of hidden content type of the documentation helper
""" """
return getattr(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):
""" """
Returns the uri's list of hidden content type of the documentation helper Returns the uri's list of hidden content type of the documentation helper
""" """
hidden_content_type_list = self.getHiddenContentTypeList() hidden_content_type_list = self.getHiddenContentTypeList()
return map(lambda x: ('%s/%s' % (self.uri, x)), hidden_content_type_list) return map(lambda x: ('%s/%s' % (self.uri, x)), hidden_content_type_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getBaseCategoryList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryList')
def getBaseCategoryList(self): def getBaseCategoryList(self):
""" """
Returns the list of base category of the documentation helper Returns the list of base category of the documentation helper
""" """
return getattr(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
...@@ -237,36 +173,32 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -237,36 +173,32 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
else: else:
return 'No' return 'No'
security.declareProtected( Permissions.AccessContentsInformation, 'getPropertySheetList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPropertySheetList')
def getPropertySheetList(self): def getPropertySheetList(self):
""" """
Returns the list of property sheets for the documentation helper Returns the list of property sheets for the documentation helper
""" """
id = getattr(self.getDocumentedObject(), "id", '') temp_object = self.getTempInstance(self.getId())
temp_object = self.getTempInstance(id) property_sheet = [obj.__name__ for obj in temp_object.property_sheets]
property_sheet = [] property_sheet += self.getDocumentedObject().property_sheet_list
for obj in temp_object.property_sheets:
property_sheet.append(obj.__module__.split('.')[-1])
for obj in self.getDocumentedObject().property_sheet_list:
property_sheet.append(obj)
return property_sheet return property_sheet
security.declareProtected( Permissions.AccessContentsInformation, 'getPropertySheetURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPropertySheetUriList')
def getPropertySheetURIList(self): def getPropertySheetUriList(self):
""" """
Returns the uri's list of property sheets for the documentation helper Returns the uri's list of property sheets for the documentation helper
""" """
property_sheet_list = self.getPropertySheetList() property_sheet_list = self.getPropertySheetList()
return map(lambda x: ('%s/%s.py' % (self.uri, x)), property_sheet_list) return map(lambda x: ('%s/%s.py' % (self.uri, x)), property_sheet_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getGroupList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getGroupList')
def getGroupList(self): def getGroupList(self):
""" """
Returns the list of groups for the documentation helper Returns the list of groups for the documentation helper
""" """
return getattr(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):
""" """
""" """
...@@ -276,7 +208,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -276,7 +208,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
action_list.append(action.getId()) action_list.append(action.getId())
return action_list return action_list
security.declareProtected( Permissions.AccessContentsInformation, 'getActionItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getActionItemList')
def getActionItemList(self): def getActionItemList(self):
""" """
""" """
...@@ -289,25 +221,14 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -289,25 +221,14 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
action_list.append((action.getId(), action.title, action.Description(), permission, visible, category)) action_list.append((action.getId(), action.title, action.Description(), permission, visible, category))
return action_list return action_list
security.declareProtected( Permissions.AccessContentsInformation, 'getActionURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getActionUriList')
def getActionURIList(self):
"""
"""
action_item_list = self.getActionItemList()
klass = self.getDocumentedObject().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4], x[5]), action_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getActionUriList' )
def getActionUriList(self): def getActionUriList(self):
""" """
""" """
action_id_list = self.getActionIdList() action_id_list = self.getActionIdList()
return map(lambda x: ('%s/%s' % (self.uri, x)), action_id_list) return map(lambda x: ('%s?_actions#%s' % (self.uri, x)), action_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getRoleIdList')
def getRoleIdList(self): def getRoleIdList(self):
""" """
""" """
...@@ -317,7 +238,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -317,7 +238,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
role_list.append(role.Title()) role_list.append(role.Title())
return role_list return role_list
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getRoleItemList')
def getRoleItemList(self): def getRoleItemList(self):
""" """
""" """
...@@ -326,7 +247,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -326,7 +247,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
role_list.append((role.__name__, role.Title(), role.Description())) role_list.append((role.__name__, role.Title(), role.Description()))
return role_list return role_list
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getRoleURIList')
def getRoleURIList(self): def getRoleURIList(self):
""" """
""" """
...@@ -337,41 +258,27 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -337,41 +258,27 @@ 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[0]), x[1], x[2]), role_item_list) return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2]), role_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleUriList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getRoleUriList')
def getRoleUriList(self): def getRoleUriList(self):
""" """
""" """
role_id_list = self.getRoleIdList() role_id_list = self.getRoleIdList()
return map(lambda x: ('%s/%s' % (self.uri, x)), role_id_list) return map(lambda x: ('%s?_roles#%s' % (self.uri, x)), role_id_list)
def _getPropertyHolder(self): def _getPropertyHolder(self):
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)
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__)]
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList')
def getWorkflowMethodIdList(self, inherited=1): def getWorkflowMethodIdList(self):
""" """
""" """
return self._getPropertyHolder().getWorkflowMethodIdList() return self._getPropertyHolder().getWorkflowMethodIdList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodUriList')
def getWorkflowMethodURIList(self, inherited=1, local=1): def getWorkflowMethodUriList(self):
"""
Returns a list of URIs to workflow methods
"""
method_id_list = self.getWorkflowMethodIdList()
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '' #'%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodUriList' )
def getWorkflowMethodUriList(self, inherited=1, local=1):
""" """
Returns a list of URIs to workflow methods Returns a list of URIs to workflow methods
""" """
...@@ -384,21 +291,21 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -384,21 +291,21 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
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, 'getClassMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodIdList')
def getClassMethodIdList(self, inherited=1, local=1): def getClassMethodIdList(self, **kw):
""" """
Return a list of tuple (id, method) for every class method Return a list of tuple (id, method) for every class method
""" """
portal_type = getPortalType(self.uri) portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0] klass = self.getTempInstance(portal_type).__class__.__bases__[0]
return self._getPropertyHolder().getClassMethodIdList(klass, inherited=inherited, local=local) return self._getPropertyHolder().getClassMethodIdList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodUriList')
def getClassMethodURIList(self, inherited=1, local=1): def getClassMethodUriList(self, inherited=0, **kw):
""" """
Returns a list of URIs to class methods Returns a list of URIs to class methods
""" """
method_id_list = self.getClassMethodIdList(inherited=inherited, local=local) method_id_list = self.getClassMethodIdList(inherited=inherited, **kw)
portal_type = getPortalType(self.uri) portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0] klass = self.getTempInstance(portal_type).__class__.__bases__[0]
class_name = klass.__name__ class_name = klass.__name__
...@@ -406,31 +313,18 @@ class PortalTypeDocumentationHelper(DocumentationHelper): ...@@ -406,31 +313,18 @@ 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, 'getAccessorMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodIdList')
def getAccessorMethodIdList(self, inherited=1): def getAccessorMethodIdList(self):
""" """
""" """
return self._getPropertyHolder().getAccessorMethodIdList() return self._getPropertyHolder().getAccessorMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodUriList')
def getAccessorMethodURIList(self, inherited=1, local=1): def getAccessorMethodUriList(self):
"""
Returns a list of URIs to accessor methods
"""
method_id_list = self.getAccessorMethodIdList(inherited=inherited)
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodUriList' )
def getAccessorMethodUriList(self, inherited=1, local=1):
""" """
Returns a list of URIs to accessor methods Returns a list of URIs to accessor methods
""" """
method_id_list = self.getAccessorMethodIdList(inherited=inherited) method_id_list = self.getAccessorMethodIdList()
portal_type = getPortalType(self.uri) portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0] klass = self.getTempInstance(portal_type).__class__.__bases__[0]
class_name = klass.__name__ class_name = klass.__name__
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -42,195 +41,153 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper): ...@@ -42,195 +41,153 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): _section_list = (
self.uri = uri dict(
id='workflow_method',
def getInstance(self): title='Workflow Method',
return self.getPortalObject().restrictedTraverse(self.uri) class_name='WorkflowMethodDocumentationHelper',
),
# API Implementation dict(
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' ) id='accessor_method',
def getTitle(self): title='Accessor',
""" class_name='AccessorMethodDocumentationHelper',
Returns the title of the documentation helper ),
""" dict(
return self.getInstance().getTitleOrId() id='class_method',
title='Class Methods',
security.declareProtected( Permissions.AccessContentsInformation, 'getType' ) class_name='ClassMethodDocumentationHelper',
),
)
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Portal Type Instance" return "Portal Type Instance"
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getPortalType')
def getSectionList(self):
"""
Returns a list of documentation sections
"""
section_list = []
if self.getWorkflowMethodURIList(inherited=0) != []:
section_list.append(
DocumentationSection(
id='workflow_method',
title='Workflow Method',
class_name='WorkflowMethodDocumentationHelper',
uri_list=self.getWorkflowMethodURIList(inherited=0),
)
)
if self.getAccessorMethodURIList(inherited=0) != []:
section_list.append(
DocumentationSection(
id='accessor',
title='Accessor',
class_name='AccessorMethodDocumentationHelper',
uri_list=self.getAccessorMethodURIList(inherited=0),
)
)
if self.getClassMethodURIList(inherited=0) != []:
section_list.append(
DocumentationSection(
id='class_method',
title='Class Methods',
class_name='ClassMethodDocumentationHelper',
uri_list=self.getClassMethodURIList(inherited=0),
)
)
return map(lambda x: x.__of__(self.getInstance()), section_list)
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalType' )
def getPortalType(self): def getPortalType(self):
""" """
""" """
return self.getInstance().getPortalType() return self.getDocumentedObject().getPortalType()
def _getPropertyHolder(self):
from Products.ERP5Type.Base import Base
property_holder = None
key = (self.getPortalType(), self.getInstance().__class__)
if not(Base.aq_portal_type.has_key(key)):
self.getInstance().initializePortalTypeDynamicProperties()
property_holder = Base.aq_portal_type[(self.getPortalType(), self.getInstance().__class__)]
return property_holder
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodItemList')
def getAccessorMethodItemList(self): def getAccessorMethodItemList(self):
""" """
""" """
return self._getPropertyHolder().getAccessorMethodItemList() return self._getPropertyHolder().getAccessorMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodIdList')
def getAccessorMethodIdList(self, inherited=1): def getAccessorMethodIdList(self):
""" """
""" """
return self._getPropertyHolder().getAccessorMethodIdList() return self._getPropertyHolder().getAccessorMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodUriList')
def getAccessorMethodURIList(self, inherited=1, local=1): def getAccessorMethodUriList(self):
""" """
Returns a list of URIs to accessor methods Returns a list of URIs to accessor methods
""" """
method_id_list = self.getAccessorMethodIdList(inherited=inherited) method_id_list = self.getAccessorMethodIdList()
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name) uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list) return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodItemList')
def getWorkflowMethodItemList(self): def getWorkflowMethodItemList(self):
""" """
""" """
return self._getPropertyHolder().getWorkflowMethodItemList() return self._getPropertyHolder().getWorkflowMethodItemList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowObject' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowObject')
def getWorkflowObject(self): def getWorkflowObject(self):
""" """
""" """
return self._getPropertyHolder() return self._getPropertyHolder()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList')
def getWorkflowMethodIdList(self, inherited=1): def getWorkflowMethodIdList(self):
""" """
""" """
return self._getPropertyHolder().getWorkflowMethodIdList() return self._getPropertyHolder().getWorkflowMethodIdList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodUriList')
def getWorkflowMethodURIList(self, inherited=1, local=1): def getWorkflowMethodUriList(self):
""" """
Returns a list of URIs to workflow methods Returns a list of URIs to workflow methods
""" """
method_id_list = self.getWorkflowMethodIdList() method_id_list = self.getWorkflowMethodIdList()
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '' #'%s.%s.' % (module, class_name) uri_prefix = '' #'%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list) return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodItemList')
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodItemList' )
def getActionMethodItemList(self): def getActionMethodItemList(self):
""" """
""" """
return self._getPropertyHolder().getActionMethodItemList() return self._getPropertyHolder().getActionMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getActionMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodIdList')
def getActionMethodIdList(self): def getActionMethodIdList(self):
""" """
""" """
return self._getPropertyHolder().getActionMethodIdList() return self._getPropertyHolder().getActionMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodItemList')
def getClassMethodItemList(self, inherited=1, local=1): def getClassMethodItemList(self, **kw):
""" """
Return a list of tuple (id, method) for every class method Return a list of tuple (id, method) for every class method
""" """
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassMethodItemList(klass, inherited=inherited, local=local) return self._getPropertyHolder().getClassMethodItemList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodIdList')
def getClassMethodIdList(self, inherited=1, local=1): def getClassMethodIdList(self, **kw):
""" """
Return a list of tuple (id, method) for every class method Return a list of tuple (id, method) for every class method
""" """
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassMethodIdList(klass, inherited=inherited, local=local) return self._getPropertyHolder().getClassMethodIdList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodURIList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodUriList')
def getClassMethodURIList(self, inherited=1, local=1): def getClassMethodUriList(self, inherited=0, **kw):
""" """
Returns a list of URIs to class methods Returns a list of URIs to class methods
""" """
method_id_list = self.getClassMethodIdList(inherited=inherited, local=local) method_id_list = self.getClassMethodIdList(inherited=inherited, **kw)
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
class_name = klass.__name__ class_name = klass.__name__
module = klass.__module__ module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name) uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list) return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassPropertyItemList')
def getClassPropertyItemList(self, inherited=1, local=1): def getClassPropertyItemList(self, **kw):
""" """
Return a list of tuple (id, method) for every class method Return a list of tuple (id, method) for every class method
""" """
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassPropertyItemList(klass, inherited=inherited, local=local) return self._getPropertyHolder().getClassPropertyItemList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getClassPropertyIdList')
def getClassPropertyIdList(self, inherited=1, local=1): def getClassPropertyIdList(self, **kw):
""" """
Return a list of tuple (id, method) for every class method Return a list of tuple (id, method) for every class method
""" """
klass = self.getInstance().__class__ klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassPropertyIdList(klass, inherited=inherited, local=local) return self._getPropertyHolder().getClassPropertyIdList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getGeneratedPropertyIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getGeneratedPropertyIdList')
def getGeneratedPropertyIdList(self): def getGeneratedPropertyIdList(self):
""" """
""" """
security.declareProtected( Permissions.AccessContentsInformation, 'getGeneratedBaseCategoryIdList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getGeneratedBaseCategoryIdList')
def getGeneratedBaseCategoryIdList(self): def getGeneratedBaseCategoryIdList(self):
""" """
""" """
......
...@@ -26,12 +26,13 @@ ...@@ -26,12 +26,13 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
# XXX Use lxml instead.
try: try:
from libxml2 import parseDoc, parserError from libxml2 import parseDoc, parserError
import_succeed = 1 import_succeed = 1
...@@ -47,32 +48,28 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper): ...@@ -47,32 +48,28 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Property Sheet" return "Property Sheet"
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
""" """
name = getattr(self.getDocumentedObject(), "name", '') return self.uri.rsplit("/",1)[-1][:-3]
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 getattr(self.getDocumentedObject(), "name", '') return self.getDocumentedObject().name
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' ) security.declareProtected(Permissions.AccessContentsInformation, 'getSourceCode')
def getSourceCode(self): def getSourceCode(self):
""" """
Returns the source code the property sheet Returns the source code the property sheet
...@@ -132,5 +129,4 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper): ...@@ -132,5 +129,4 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper):
return source_code return source_code
InitializeClass(PortalTypePropertySheetDocumentationHelper) InitializeClass(PortalTypePropertySheetDocumentationHelper)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,53 +38,21 @@ class PortalTypeRoleDocumentationHelper(DocumentationHelper): ...@@ -39,53 +38,21 @@ class PortalTypeRoleDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
documented_object = self.getDocumentedObject()
if documented_object is not None:
return documented_object.Description()
else:
return ''
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Portal Type Role" return "Portal Type Role"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getCategoryList')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
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 getattr(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
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
......
...@@ -26,12 +26,10 @@ ...@@ -26,12 +26,10 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class ScriptPythonDocumentationHelper(DocumentationHelper): class ScriptPythonDocumentationHelper(DocumentationHelper):
""" """
...@@ -40,38 +38,21 @@ class ScriptPythonDocumentationHelper(DocumentationHelper): ...@@ -40,38 +38,21 @@ class ScriptPythonDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Script Python" return "Script Python"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getParams')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getParams' )
def getParams(self): def getParams(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return getattr(self.getDocumentedObject(), "_params", '') return getattr(self.getDocumentedObject(), "_params", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' ) security.declareProtected(Permissions.AccessContentsInformation, 'getSourceCode')
def getSourceCode(self): def getSourceCode(self):
""" """
Returns the source code the script python Returns the source code the script python
...@@ -97,7 +78,7 @@ class ScriptPythonDocumentationHelper(DocumentationHelper): ...@@ -97,7 +78,7 @@ class ScriptPythonDocumentationHelper(DocumentationHelper):
source_html = portal_transforms.convertTo(mime_type, source_code, mimetype = src_mimetype) source_html = portal_transforms.convertTo(mime_type, source_code, mimetype = src_mimetype)
return source_html.getData() return source_html.getData()
security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' ) security.declareProtected(Permissions.AccessContentsInformation, 'getDefinition')
def getDefinition(self): def getDefinition(self):
""" """
Returns the definition of the script with the name of the script and arguments Returns the definition of the script with the name of the script and arguments
......
...@@ -26,11 +26,10 @@ ...@@ -26,11 +26,10 @@
# #
############################################################################## ##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
class SkinFolderDocumentationHelper(DocumentationHelper): class SkinFolderDocumentationHelper(DocumentationHelper):
...@@ -40,118 +39,75 @@ class SkinFolderDocumentationHelper(DocumentationHelper): ...@@ -40,118 +39,75 @@ class SkinFolderDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): _section_list = (
self.uri = uri dict(
id='erp5_form',
title='ERP5 Form',
class_name='ERP5FormDocumentationHelper',
),
dict(
id='zsql_method',
title='Z SQL Method',
class_name='ZSQLMethodDocumentationHelper',
),
dict(
id='page_template',
title='Page Template',
class_name='PageTemplateDocumentationHelper',
),
dict(
id='script_python',
title='Script (Python)',
class_name='ScriptPythonDocumentationHelper',
),
)
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getSectionList(self):
"""
Returns a list of documentation sections
"""
section_list = []
if self.getFileURIList(meta_type='ERP5 Form') != []:
section_list.append(
DocumentationSection(
id='erp5_form',
title='ERP5 Form',
class_name='ERP5FormDocumentationHelper',
uri_list=self.getFileURIList(meta_type='ERP5 Form'),
)
)
if self.getFileURIList(meta_type='Z SQL Method') != []:
section_list.append(
DocumentationSection(
id='zsql_method',
title='Z SQL Method',
class_name='ZSQLMethodDocumentationHelper',
uri_list=self.getFileURIList(meta_type='Z SQL Method'),
)
)
if self.getFileURIList(meta_type='Page Template') != []:
section_list.append(
DocumentationSection(
id='page_template',
title='Page Template',
class_name='PageTemplateDocumentationHelper',
uri_list=self.getFileURIList(meta_type='Page Template'),
)
)
if self.getFileURIList(meta_type='Script (Python)') != []:
section_list.append(
DocumentationSection(
id='script_python',
title='Script (Python)',
class_name='ScriptPythonDocumentationHelper',
uri_list=self.getFileURIList(meta_type='Script (Python)'),
)
)
return map(lambda x: x.__of__(self), section_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Skin Folder" return "Skin Folder"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getMetaTypeList')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getMetaTypeList' )
def getMetaTypeList(self): def getMetaTypeList(self):
meta_type_dict = {} return sorted(set(obj.meta_type
for file in self.getDocumentedObject().objectValues(): for obj in self.getDocumentedObject().objectValues()))
meta_type_dict[file.meta_type] = None
type_list = meta_type_dict.keys()
type_list.sort()
return type_list
security.declareProtected(Permissions.AccessContentsInformation, 'getFileIdList' ) def getFileValueList(self, meta_type=None):
return (obj for obj in self.getDocumentedObject().objectValues()
if meta_type in (None, obj.meta_type))
security.declareProtected(Permissions.AccessContentsInformation, 'getFileIdList')
def getFileIdList(self, meta_type=None): def getFileIdList(self, meta_type=None):
""" """
Returns the list of sub-objects ids of the documentation helper Returns the list of sub-objects ids of the documentation helper
""" """
file_list = [] return [obj.id for obj in self.getFileValueList(meta_type)]
files = self.getDocumentedObject()
if files is not None:
for file in files.objectValues():
if not meta_type or file.meta_type == meta_type:
file_list.append(file.id)
return file_list
security.declareProtected(Permissions.AccessContentsInformation, 'getFileItemList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getFileItemList')
def getFileItemList(self, meta_type=None): def getFileItemList(self, meta_type=None):
""" """
Returns the list of sub-objects items of the documentation helper Returns the list of sub-objects items of the documentation helper
""" """
file_list = [] obj_list = []
files = self.getDocumentedObject() for obj in self.getFileValueList(meta_type):
if files is not None: obj = aq_base(obj)
for file in files.objectValues(): obj_list.append((obj.id,
if not meta_type or file.meta_type == meta_type: getattr(obj, "title", ""),
file_list.append((file.id, getattr(obj, "description", ""),
getattr(file, "title", ""), getattr(obj, "meta_type", "")))
getattr(file, "description", ""), return obj_list
getattr(file, "meta_type", "")))
return file_list security.declareProtected(Permissions.AccessContentsInformation, 'getFileUriList')
security.declareProtected( Permissions.AccessContentsInformation, 'getFileURIList' ) def getFileUriList(self, meta_type=None):
def getFileURIList(self, meta_type=None):
""" """
""" """
file_list = self.getFileIdList(meta_type) prefix = self.uri + '/'
base_uri = '/%s/portal_skins/%s' % (self.getPortalObject().id, self.getDocumentedObject().id) return [prefix + obj.id for obj in self.getFileValueList(meta_type)]
return map(lambda x: ('%s/%s' % (base_uri, x)), file_list)
def getSectionUriList(self, title, **kw):
return self.getFileUriList(title)
InitializeClass(SkinFolderDocumentationHelper) InitializeClass(SkinFolderDocumentationHelper)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,31 +38,14 @@ class SkinFolderItemDocumentationHelper(DocumentationHelper): ...@@ -39,31 +38,14 @@ class SkinFolderItemDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return getattr(self.getDocumentedObject(), "meta_type", '') return getattr(self.getDocumentedObject(), "meta_type", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getContentType')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
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
......
...@@ -26,12 +26,10 @@ ...@@ -26,12 +26,10 @@
# #
############################################################################## ##############################################################################
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, getCallableSignatureString
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class WorkflowMethodDocumentationHelper(DocumentationHelper): class WorkflowMethodDocumentationHelper(DocumentationHelper):
""" """
...@@ -40,39 +38,32 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper): ...@@ -40,39 +38,32 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription') security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self): def getDescription(self):
return getattr(self.getDocumentedObject(), "__doc__", '') """
"""
return self.getDocumentedObject().__doc__
security.declareProtected(Permissions.AccessContentsInformation, 'getType' ) security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Workflow Method" return "Workflow Method"
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
""" """
# XXX May return _doNothing
return getattr(self.getDocumentedObject(), "_transition_id", '') return getattr(self.getDocumentedObject(), "_transition_id", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' ) security.declareProtected(Permissions.AccessContentsInformation, 'getDefinition')
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' )
def getDefinition(self): def getDefinition(self):
""" """
Returns the definition of the workflow_method with the name and arguments Returns the definition of the workflow_method with the name and arguments
""" """
return getDefinitionString(self.getDocumentedObject()) return getCallableSignatureString(self.getDocumentedObject().im_func._m)
InitializeClass(WorkflowMethodDocumentationHelper) InitializeClass(WorkflowMethodDocumentationHelper)
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
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
...@@ -39,31 +38,14 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper): ...@@ -39,31 +38,14 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri): security.declareProtected(Permissions.AccessContentsInformation, 'getType')
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self): def getType(self):
""" """
Returns the type of the documentation helper Returns the type of the documentation helper
""" """
return "Z SQL Method" return "Z SQL Method"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getSource')
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getSource' )
def getSource(self): def getSource(self):
""" """
Returns the source code of the documentation helper Returns the source code of the documentation helper
...@@ -85,35 +67,35 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper): ...@@ -85,35 +67,35 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper):
source_html = portal_transforms.convertTo(mime_type, source_code, mimetype = src_mimetype) source_html = portal_transforms.convertTo(mime_type, source_code, mimetype = src_mimetype)
return source_html.getData() return source_html.getData()
security.declareProtected(Permissions.AccessContentsInformation, 'getConnectionId' ) security.declareProtected(Permissions.AccessContentsInformation, 'getConnectionId')
def getConnectionId(self): def getConnectionId(self):
""" """
Returns the title of the documentation helper Returns the title of the documentation helper
""" """
return getattr(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 getattr(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 getattr(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 getattr(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
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
...@@ -49,7 +50,6 @@ from WorkflowMethodDocumentationHelper import WorkflowMethodDocumentationHelper ...@@ -49,7 +50,6 @@ from WorkflowMethodDocumentationHelper import WorkflowMethodDocumentationHelper
from DCWorkflowStateDocumentationHelper import DCWorkflowStateDocumentationHelper from DCWorkflowStateDocumentationHelper import DCWorkflowStateDocumentationHelper
from DCWorkflowTransitionDocumentationHelper import DCWorkflowTransitionDocumentationHelper from DCWorkflowTransitionDocumentationHelper import DCWorkflowTransitionDocumentationHelper
from DCWorkflowVariableDocumentationHelper import DCWorkflowVariableDocumentationHelper from DCWorkflowVariableDocumentationHelper import DCWorkflowVariableDocumentationHelper
from DCWorkflowPermissionDocumentationHelper import DCWorkflowPermissionDocumentationHelper
from DCWorkflowWorklistDocumentationHelper import DCWorkflowWorklistDocumentationHelper from DCWorkflowWorklistDocumentationHelper import DCWorkflowWorklistDocumentationHelper
from DCWorkflowScriptDocumentationHelper import DCWorkflowScriptDocumentationHelper from DCWorkflowScriptDocumentationHelper import DCWorkflowScriptDocumentationHelper
from SkinFolderDocumentationHelper import SkinFolderDocumentationHelper from SkinFolderDocumentationHelper import SkinFolderDocumentationHelper
......
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