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 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from DocumentationHelper import DocumentationHelper, getCallableSignatureString
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):
"""
Provides documentation about an accessor
......@@ -75,54 +38,55 @@ class AccessorMethodDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(self):
"""
"""
obj = self.getDocumentedObject()
if obj is not None:
return obj.__name__
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
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):
"""
Returns the type of the documentation helper
"""
return "Accessor Method"
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getArgCount')
def getArgCount(self):
"""
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):
"""
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):
"""
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)
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -38,32 +37,28 @@ class BaseCategoryDocumentationHelper(DocumentationHelper):
Provides access to all documentation information
of a portal type instance.
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
def getInstance(self):
return self.getPortalObject().restrictedTraverse(self.uri)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getInstance().getTitleOrId()
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getInstance(), 'description', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
_section_list = (
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):
"""
Returns the type of the documentation helper
......@@ -75,208 +70,173 @@ class BaseCategoryDocumentationHelper(DocumentationHelper):
"""
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')
def getAcquisitionMaskValue(self):
"""
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')
def getAcquisitionCopyValue(self):
"""
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')
def getAcquisitionSyncValue(self):
"""
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')
def getAcquisitionBaseCategoryList(self):
"""
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')
def getAcquisitionObjectIds(self):
"""
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')
def getAcquisitionPortalType(self):
"""
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')
def getAcquisitionCategoryType(self):
"""
Returns the acquisitions ids of the documented base category
"""
return getattr(self.getInstance(), '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()),
]
return getattr(self.getDocumentedObject(), 'category_type', [])
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalType')
def getPortalType(self):
"""
"""
return self.getInstance().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
return self.getDocumentedObject().getPortalType()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodItemList')
def getAccessorMethodItemList(self):
"""
"""
return self._getPropertyHolder().getAccessorMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' )
def getAccessorMethodIdList(self, inherited=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodIdList')
def getAccessorMethodIdList(self):
"""
"""
return self._getPropertyHolder().getAccessorMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodURIList' )
def getAccessorMethodURIList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodUriList')
def getAccessorMethodUriList(self):
"""
Returns a list of URIs to accessor methods
"""
method_id_list = self.getAccessorMethodIdList(inherited=inherited)
klass = self.getInstance().__class__
method_id_list = self.getAccessorMethodIdList()
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), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodItemList')
def getWorkflowMethodItemList(self):
"""
"""
return self._getPropertyHolder().getWorkflowMethodItemList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowObject' )
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowObject')
def getWorkflowObject(self):
"""
"""
return self._getPropertyHolder()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' )
def getWorkflowMethodIdList(self, inherited=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList')
def getWorkflowMethodIdList(self):
"""
"""
return self._getPropertyHolder().getWorkflowMethodIdList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodURIList' )
def getWorkflowMethodURIList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodUriList')
def getWorkflowMethodUriList(self):
"""
Returns a list of URIs to workflow methods
"""
method_id_list = self.getWorkflowMethodIdList()
klass = self.getInstance().__class__
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), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodItemList')
def getActionMethodItemList(self):
"""
"""
return self._getPropertyHolder().getActionMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getActionMethodIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodIdList')
def getActionMethodIdList(self):
"""
"""
return self._getPropertyHolder().getActionMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodItemList' )
def getClassMethodItemList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodItemList')
def getClassMethodItemList(self, **kw):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassMethodItemList(klass, inherited=inherited, local=local)
klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassMethodItemList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodIdList' )
def getClassMethodIdList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodIdList')
def getClassMethodIdList(self, **kw):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassMethodIdList(klass, inherited=inherited, local=local)
klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassMethodIdList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodURIList' )
def getClassMethodURIList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodUriList')
def getClassMethodUriList(self, inherited=0, **kw):
"""
Returns a list of URIs to class methods
"""
method_id_list = self.getClassMethodIdList(inherited=inherited, local=local)
klass = self.getInstance().__class__
method_id_list = self.getClassMethodIdList(inherited=inherited, **kw)
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), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyItemList' )
def getClassPropertyItemList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassPropertyItemList')
def getClassPropertyItemList(self, **kw):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassPropertyItemList(klass, inherited=inherited, local=local)
klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassPropertyItemList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyIdList' )
def getClassPropertyIdList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassPropertyIdList')
def getClassPropertyIdList(self, **kw):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassPropertyIdList(klass, inherited=inherited, local=local)
klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassPropertyIdList(klass, **kw)
InitializeClass(BaseCategoryDocumentationHelper)
......@@ -27,7 +27,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,140 +38,90 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
Provides access to all documentation information
of a business template.
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), 'title', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
_section_list = (
dict(
id='portal_type',
title='Portal Types',
class_name='PortalTypeDocumentationHelper',
),
dict(
id='dc_workflow',
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):
"""
Returns the type of the documentation helper
"""
return "Business Template"
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getVersion')
def getVersion(self):
"""
Returns the version of the business template
"""
return getattr(self.getDocumentedObject(), 'version', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getRevisionNumber' )
security.declareProtected(Permissions.AccessContentsInformation, 'getRevisionNumber')
def getRevisionNumber(self):
"""
Returns the revision number of the documentation helper
"""
return getattr(self.getDocumentedObject(), 'revision', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getBuildingState' )
security.declareProtected(Permissions.AccessContentsInformation, 'getBuildingState')
def getBuildingState(self):
"""
Returns the building_state of the documentation helper
"""
return self.getDocumentedObject().getBuildingState()
security.declareProtected( Permissions.AccessContentsInformation, 'getInstallationState' )
security.declareProtected(Permissions.AccessContentsInformation, 'getInstallationState')
def getInstallationState(self):
"""
Returns the installation_state of the documentation helper
"""
return self.getDocumentedObject().getInstallationState()
security.declareProtected( Permissions.AccessContentsInformation, 'getMaintainerList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getMaintainerList')
def getMaintainerList(self):
"""
Returns the list of maintainers of the business template
"""
return getattr(self.getDocumentedObject(), 'maintainer', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getDependencyList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getDependencyList')
def getDependencyList(self):
"""
Returns the list of dependencies of the business template
......@@ -180,36 +129,36 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
return getattr(self.getDocumentedObject(), 'dependency', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalTypeIdList')
def getPortalTypeIdList(self):
"""
"""
return getattr(self.getDocumentedObject(), 'template_portal_type_id', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalTypeURIList' )
def getPortalTypeURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalTypeUriList')
def getPortalTypeUriList(self):
"""
"""
portal_type_list = self.getPortalTypeIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_types'
return map(lambda x: ('%s/%s' % (base_uri, x)), portal_type_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getSkinFolderIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getSkinFolderIdList')
def getSkinFolderIdList(self):
"""
"""
return getattr(self.getDocumentedObject(), 'template_skin_id', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getSkinFolderURIList' )
def getSkinFolderURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getSkinFolderUriList')
def getSkinFolderUriList(self):
"""
"""
skin_folder_list = self.getSkinFolderIdList()
base_uri = '/' + self.getPortalObject().id + '/portal_skins'
return map(lambda x: ('%s/%s' % (base_uri, x)), skin_folder_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getDCWorkflowIdList' )
def getDCWorkflowIdList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getDcWorkflowIdList')
def getDcWorkflowIdList(self):
"""
"""
dc_workflow_list = []
......@@ -221,15 +170,15 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
dc_workflow_list.append(wf)
return dc_workflow_list
security.declareProtected( Permissions.AccessContentsInformation, 'getDCWorkflowURIList' )
def getDCWorkflowURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getDcWorkflowUriList')
def getDcWorkflowUriList(self):
"""
"""
workflow_list = self.getDCWorkflowIdList()
workflow_list = self.getDcWorkflowIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_workflow'
return map(lambda x: ('%s/%s' % (base_uri, x)), workflow_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getInteractionWorkflowIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getInteractionWorkflowIdList')
def getInteractionWorkflowIdList(self):
"""
"""
......@@ -242,57 +191,57 @@ class BusinessTemplateDocumentationHelper(DocumentationHelper):
workflow_list.append(wf)
return workflow_list
security.declareProtected( Permissions.AccessContentsInformation, 'getInteractionWorkflowURIList' )
def getInteractionWorkflowURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getInteractionWorkflowUriList')
def getInteractionWorkflowUriList(self):
"""
"""
workflow_list = self.getInteractionWorkflowIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_workflow'
return map(lambda x: ('%s/%s' % (base_uri, x)), workflow_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getBaseCategoryList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryList')
def getBaseCategoryList(self):
"""
"""
return getattr(self.getDocumentedObject(), 'template_base_category', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getBaseCategoryURIList' )
def getBaseCategoryURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryUriList')
def getBaseCategoryUriList(self):
"""
"""
base_category_list = self.getBaseCategoryList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_categories'
return map(lambda x: ('%s/%s' % (base_uri, x)), base_category_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getModuleIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getModuleIdList')
def getModuleIdList(self):
"""
"""
return getattr(self.getDocumentedObject(), 'template_module_id', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getModuleURIList' )
def getModuleURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getModuleUriList')
def getModuleUriList(self):
"""
"""
module_list = self.getModuleIdList()
base_uri = '/'+self.uri.split('/')[1]
return map(lambda x: ('%s/%s' % (base_uri, x)), module_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getCatalogMethodIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getCatalogMethodIdList')
def getCatalogMethodIdList(self):
"""
"""
return getattr(self.getDocumentedObject(), 'template_catalog_method_id', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getCatalogMethodURIList' )
def getCatalogMethodURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getCatalogMethodUriList')
def getCatalogMethodUriList(self):
"""
"""
catalog_method_list = self.getCatalogMethodIdList()
base_uri = '/'+self.uri.split('/')[1]+'/portal_catalog'
return map(lambda x: ('%s/%s' % (base_uri, x)), catalog_method_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTemplatePathList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePathList')
def getTemplatePathList(self):
"""
"""
......
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from ZSQLMethodDocumentationHelper import ZSQLMethodDocumentationHelper
......@@ -39,38 +38,21 @@ class CatalogMethodDocumentationHelper(ZSQLMethodDocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Catalog Method"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getConnectionId')
def getConnectionId(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), 'connection_id', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList')
def getArgumentList(self):
"""
Returns the arguments of the documentation helper
......@@ -82,7 +64,7 @@ class CatalogMethodDocumentationHelper(ZSQLMethodDocumentationHelper):
keys = getattr(arg, '_keys', [])
return keys
security.declareProtected(Permissions.AccessContentsInformation, 'getCatalog' )
security.declareProtected(Permissions.AccessContentsInformation, 'getCatalog')
def getCatalog(self):
"""
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 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from DocumentationHelper import DocumentationHelper, getCallableSignatureString
from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class ClassMethodDocumentationHelper(DocumentationHelper):
"""
......@@ -40,37 +38,32 @@ class ClassMethodDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return getattr(self.getDocumentedObject(), "__doc__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(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' )
def getTitle(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
"""
Returns the type of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__doc__", '')
return self.getDocumentedObject().__doc__
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
def getSectionList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
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):
"""
Returns the definition of the class_method with the name and arguments
"""
return getDefinitionString(self.getDocumentedObject())
return getCallableSignatureString(self.getDocumentedObject())
InitializeClass(ClassMethodDocumentationHelper)
......@@ -26,11 +26,9 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph
......@@ -63,123 +61,59 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
def getInstance(self):
return self.getPortalObject().restrictedTraverse(self.uri)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the Id of the documentation helper
"""
return getattr(self.getInstance(), '__name__', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
_section_list = (
dict(
id='state',
title='Workflow States',
class_name='DCWorkflowStateDocumentationHelper',
),
dict(
id='transition',
title='Workflow Transitions',
class_name='DCWorkflowTransitionDocumentationHelper',
),
dict(
id='variable',
title='Workflow Variables',
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):
"""
Returns the type of the documentation helper
"""
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
security.declareProtected( Permissions.AccessContentsInformation, 'getStateIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getStateIdList')
def getStateIdList(self):
"""
"""
state_list = []
states = getattr(self.getInstance(), 'states', None)
states = getattr(self.getDocumentedObject(), 'states', None)
if states is not None:
for state in states.objectValues():
state_list.append(state.getId())
return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getStateItemList')
def getStateItemList(self):
"""
"""
state_list = []
states = getattr(self.getInstance(), 'states', None)
states = getattr(self.getDocumentedObject(), 'states', None)
if states is not None:
for state in states.objectValues():
state_list.append((getattr(state, "id", ""),
......@@ -193,7 +127,7 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
))
return state_list
security.declareProtected( Permissions.AccessContentsInformation, 'getStateUriList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getStateUriList')
def getStateUriList(self):
"""
"""
......@@ -201,37 +135,37 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
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):
"""
"""
state_item_list = self.getStateItemList()
klass = self.getInstance().__class__
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], x[6], x[7]), state_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionIdList')
def getTransitionIdList(self):
"""
"""
transition_list = []
transitions = getattr(self.getInstance(), 'transitions', None)
transitions = getattr(self.getDocumentedObject(), 'transitions', None)
if transitions is not None:
for transition in transitions.objectValues():
transition_list.append(transition.getId())
return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionItemList')
def getTransitionItemList(self):
"""
"""
transition_list = []
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:
for transition in self.getInstance().transitions.objectValues():
for transition in self.getDocumentedObject().transitions.objectValues():
guard_roles = ""
guard = dir(transition.guard)
if hasattr(transition.guard, '__dict__'):
......@@ -245,41 +179,41 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
))
return transition_list
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionUriList' )
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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionURIList')
def getTransitionURIList(self):
"""
"""
transition_item_list = self.getTransitionItemList()
klass = self.getInstance().__class__
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]), transition_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getVariableIdList')
def getVariableIdList(self):
"""
"""
variable_list = []
variables = getattr(self.getInstance(), 'variables', None)
variables = getattr(self.getDocumentedObject(), 'variables', None)
if variables is not None:
for variable in variables.objectValues():
variable_list.append(variable.getId())
return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getVariableItemList')
def getVariableItemList(self):
"""
"""
variable_list = []
variables = getattr(self.getInstance(), 'variables', None)
variables = getattr(self.getDocumentedObject(), 'variables', None)
if variables is not None:
for variable in variables.objectValues():
variable_list.append((variable.getId(),
......@@ -288,71 +222,47 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
))
return variable_list
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getVariableURIList')
def getVariableURIList(self):
"""
"""
variable_item_list = self.getVariableItemList()
klass = self.getInstance().__class__
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]), variable_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getVariableUriList' )
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 = []
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):
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionList')
def getPermissionList(self):
"""
"""
permission_id_list = self.getPermissionIdList()
return map(lambda x: '%s/permissions/%s' % (self.uri, x), permission_id_list)
return getattr(self.getDocumentedObject(), "permissions", ())
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getWorklistIdList')
def getWorklistIdList(self):
"""
"""
worklist_list = []
worklists = getattr(self.getInstance(), "worklists", None)
worklists = getattr(self.getDocumentedObject(), "worklists", None)
if worklists is not None:
for wl in worklists.objectValues():
worklist_list.append(getattr(wl, "__name__", ''))
return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getWorklistItemList')
def getWorklistItemList(self):
"""
"""
worklist_list = []
worklists = getattr(self.getInstance(), "worklists", None)
worklists = getattr(self.getDocumentedObject(), "worklists", None)
if worklists is not None:
for wl in worklists.objectValues():
guard_roles = ""
......@@ -368,41 +278,41 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
return worklist_list
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistURIList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getWorklistURIList')
def getWorklistURIList(self):
"""
"""
worklist_item_list = self.getWorklistItemList()
klass = self.getInstance().__class__
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]), worklist_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getWorklistUriList' )
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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getScriptIdList')
def getScriptIdList(self):
"""
"""
script_list = []
scripts = getattr(self.getInstance(), "scripts", None)
scripts = getattr(self.getDocumentedObject(), "scripts", None)
if scripts is not None:
for script in scripts.objectValues():
script_list.append(getattr(script, "__name__", ''))
return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getScriptItemList')
def getScriptItemList(self):
"""
"""
script_list = []
scripts = getattr(self.getInstance(), "scripts", None)
scripts = getattr(self.getDocumentedObject(), "scripts", None)
if scripts is not None:
for script in scripts.objectValues():
script_list.append((getattr(script, "__name__", ''),
......@@ -411,25 +321,25 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
return script_list
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptURIList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getScriptURIList')
def getScriptURIList(self):
"""
"""
script_item_list = self.getScriptItemList()
klass = self.getInstance().__class__
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]), script_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getScriptUriList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getScriptUriList')
def getScriptUriList(self):
"""
"""
script_id_list = self.getScriptIdList()
return map(lambda x: ('%s/scripts/%s' % (self.uri, x)), script_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageURL' )
security.declareProtected(Permissions.AccessContentsInformation, 'getGraphImageURL')
def getGraphImageURL(self):
"""
Returns a URL to a graphic representation of the workflow
......@@ -437,11 +347,11 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
""
security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageData' )
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=getattr(self.getInstance(), "__name__", ''), format=format)
return getGraph(self, wf_id=getattr(self.getDocumentedObject(), "__name__", ''), format=format)
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 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from ScriptPythonDocumentationHelper import ScriptPythonDocumentationHelper
......@@ -36,14 +35,5 @@ class DCWorkflowScriptDocumentationHelper(ScriptPythonDocumentationHelper):
"""
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)
......@@ -26,39 +26,11 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
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):
"""
Provides documentation about a workflow state
......@@ -66,82 +38,75 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return self.getDocumentedObject().__dict__["description"]
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow State"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionList')
def getTransitionList(self):
"""
Returns list of possible transitions from this state
"""
return getattr(self.getDocumentedObject(), "transitions", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleOwner' )
return self.getDocumentedObject().transitions
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):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Owner')
return self.getPermissionsOfRole('Owner')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssignor' )
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssignor')
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):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Assignee')
return self.getPermissionsOfRole('Assignee')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssociate' )
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleAssociate')
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):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Author')
return self.getPermissionsOfRole('Author')
security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionsOfRoleAuditor' )
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleAuditor')
def getPermissionsOfRoleAuditor(self):
"""
"""
return getPermissionsOfRole(self.getDocumentedObject(),'Auditor')
return self.getPermissionsOfRole('Auditor')
InitializeClass(DCWorkflowStateDocumentationHelper)
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,50 +38,21 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
#return self.getDocumentedObject().__dict__["description"]
return getattr(self.getDocumentedObject(), "description", "")
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow Transition"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getNewStateId')
def getNewStateId(self):
"""
Returns the id of the new state for de workflow transition
"""
return getattr(self.getDocumentedObject(), "new_state_id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getTriggerType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getTriggerType')
def getTriggerType(self):
"""
Returns the trigger type for de workflow transition
......@@ -91,28 +61,28 @@ class DCWorkflowTransitionDocumentationHelper(DocumentationHelper):
trigger_type_id = getattr(self.getDocumentedObject(), "trigger_type", '')
return trigger_type_list[trigger_type_id]
security.declareProtected(Permissions.AccessContentsInformation, 'getScriptName' )
security.declareProtected(Permissions.AccessContentsInformation, 'getScriptName')
def getScriptName(self):
"""
Returns the name of the script for de workflow transition
"""
return getattr(self.getDocumentedObject(), "script_name", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAfterScriptName' )
security.declareProtected(Permissions.AccessContentsInformation, 'getAfterScriptName')
def getAfterScriptName(self):
"""
Returns the name of the script for de workflow transition
"""
return getattr(self.getDocumentedObject(), "after_script_name", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableStateIds' )
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableStateIds')
def getAvailableStateIds(self):
"""
Returns available states in the workflow
"""
return self.getDocumentedObject().getAvailableStateIds()
security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles' )
security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles')
def getGuardRoles(self):
"""
Returns roles to pass this transition
......
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,42 +38,14 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
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", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow Variable"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultExpression')
def getDefaultExpression(self):
"""
Returns the Default Expression of the documentation helper
......@@ -84,7 +55,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
default_expr = self.getDocumentedObject().default_expr.text
return default_expr
security.declareProtected(Permissions.AccessContentsInformation, 'getForCatalog' )
security.declareProtected(Permissions.AccessContentsInformation, 'getForCatalog')
def getForCatalog(self):
"""
Returns 1 if variable is available in the catalog
......@@ -98,7 +69,7 @@ class DCWorkflowVariableDocumentationHelper(DocumentationHelper):
else:
return 'No'
security.declareProtected(Permissions.AccessContentsInformation, 'getUpdateAlways' )
security.declareProtected(Permissions.AccessContentsInformation, 'getUpdateAlways')
def getUpdateAlways(self):
"""
Returns 1 if variable is available in the history
......
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,46 +38,22 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper):
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", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow Worklist"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return getattr(self.getDocumentedObject(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(self):
"""
Returns the title of the documentation helper
"""
if self.getDocumentedObject().title == "":
return self.getDocumentedObject().actbox_name
else:
return self.getDocumentedObject().title
return DocumentationHelper.getTitle(self) \
or self.getDocumentedObject().actbox_name
security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles' )
security.declareProtected(Permissions.AccessContentsInformation, 'getGuardRoles')
def getGuardRoles(self):
"""
Returns roles to pass this worklist
......@@ -91,7 +66,7 @@ class DCWorkflowWorklistDocumentationHelper(DocumentationHelper):
role_list = self.getDocumentedObject().guard.__dict__['roles']
return ', '.join(role for role in role_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getVarMatches' )
security.declareProtected(Permissions.AccessContentsInformation, 'getVarMatches')
def getVarMatches(self):
"""
Returns variables and values to match worklist
......
......@@ -26,13 +26,16 @@
#
##############################################################################
from Acquisition import Implicit
from Acquisition import Implicit, aq_base
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from Products.ERP5Type import Permissions
from App.config import getConfiguration
import os
import random
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Utils import convertToUpperCase
from DocumentationSection import DocumentationSection
class TempObjectLibrary(object):
......@@ -70,6 +73,27 @@ class TempObjectLibrary(object):
self.portal_type_dict[portal_type] = 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):
"""
Example URIs
......@@ -83,16 +107,25 @@ class DocumentationHelper(Implicit):
Products.ERP5Type.Document.Person.notify
Products.ERP5Type.Document.Person.isRAD
portal_types/Person
portal_types/Person/actions#view
portal_types/Person?_actions#view
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
_section_list = ()
# Methods to override
def __init__(self, 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):
"""
Returns a temporary instance of the given portal_type
......@@ -175,12 +208,13 @@ class DocumentationHelper(Implicit):
#documented_object = imp.load_module(fp, pathname, description)
return documented_object
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(self):
"""
Returns the title of the documentation helper
(ex. class name)
"""
raise NotImplemented
return getattr(aq_base(self.getDocumentedObject()), 'title', '')
def getType(self):
"""
......@@ -189,12 +223,28 @@ class DocumentationHelper(Implicit):
"""
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')
def getSectionList(self):
"""
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')
def getURI(self):
......@@ -212,7 +262,7 @@ class DocumentationHelper(Implicit):
"""
return self.__class__.__name__
security.declareProtected(Permissions.AccessContentsInformation, 'view')
security.declareProtected(Permissions.View, 'view')
def view(self):
"""
Renders the documentation with a standard form
......@@ -220,8 +270,17 @@ class DocumentationHelper(Implicit):
"""
return getattr(self, '%s_view' % self.getClassName())()
security.declareProtected(Permissions.AccessContentsInformation, '__call__')
security.declareProtected(Permissions.View, '__call__')
def __call__(self):
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)
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,42 +38,18 @@ class ERP5FormDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "ERP5 Form"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getEncoding')
def getEncoding(self):
"""
Returns the encoding of the ERP5 Form
"""
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)
......@@ -27,11 +27,9 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
class ERP5SiteDocumentationHelper(DocumentationHelper):
......@@ -39,77 +37,44 @@ class ERP5SiteDocumentationHelper(DocumentationHelper):
Provides access to all documentation information
of an ERP5 Site.
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "title", '')
_section_list = (
dict(
id='business_template',
title='Business Template',
class_name='BusinessTemplateDocumentationHelper',
),
)
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "ERP5 Site"
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
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", '')
def getBusinessTemplateValueList(self):
bt_list = getattr(self, 'REQUEST', {}).get("business_template_list")
return (bt for bt in self.getPortalObject().portal_templates.objectValues()
if bt_list is None or bt.getTitle() in bt_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getBusinessTemplateItemList')
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(),
getattr(bt, "title", ''),
getattr(bt, "description", ''),
getattr(bt, "version", ''),
getattr(bt, "revision", ''))
for bt in self.getDocumentedObject().portal_templates.objectValues()
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)
for bt in self.getBusinessTemplateValueList()]
security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateUriList' )
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])), bt_list)
return [bt.getPath() for bt in self.getBusinessTemplateValueList()]
InitializeClass(ERP5SiteDocumentationHelper)
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......
......@@ -26,399 +26,28 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from DCWorkflowStateDocumentationHelper import DCWorkflowStateDocumentationHelper
from Products.ERP5Type import Permissions
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph
def getStatePermissionsOfRole(state=None, role=''):
permissions = ""
if state != None:
if hasattr(state, '__dict__'):
if 'permission_roles' in state.__dict__.keys():
if 'View' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['View']:
permissions += "V"
if 'Access contents information' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Access contents information']:
permissions += "A"
if 'Modify portal content' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Modify portal content']:
permissions += "M"
if 'Add portal content' in state.__dict__['permission_roles'].keys():
if role in state.__dict__['permission_roles']['Add portal content']:
permissions += "C"
return permissions
# XXX To be implemented. For the moment,
# make it a subclass of DCWorkflowStateDocumentationHelper.
class InteractionWorkflowDocumentationHelper(DocumentationHelper):
class InteractionWorkflowDocumentationHelper(DCWorkflowStateDocumentationHelper):
"""
Provides access to all documentation information
of an interaction workflow.
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
def getInstance(self):
return self.getPortalObject().restrictedTraverse(self.uri)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the Id of the documentation helper
"""
return getattr(self.getInstance(), "__name__", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Interaction Workflow"
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return 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)
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,40 +38,14 @@ class PageTemplateDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Page Template"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getSourceCode')
def getSourceCode(self):
"""
Returns the source code the script python
......
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,45 +38,14 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Portal Type Action"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissions')
def getPermissions(self):
"""
Returns the permissions of the documentation helper
......@@ -85,7 +53,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
permissions = getattr(self.getDocumentedObject(), "permissions", [])
return ', '.join(x for x in permissions)
security.declareProtected(Permissions.AccessContentsInformation, 'getVisible' )
security.declareProtected(Permissions.AccessContentsInformation, 'getVisible')
def getVisible(self):
"""
Returns the visibility of the documentation helper
......@@ -93,7 +61,7 @@ class PortalTypeActionDocumentationHelper(DocumentationHelper):
TITLE =['No', 'Yes']
return TITLE[getattr(self.getDocumentedObject(), "visible", 0)]
security.declareProtected(Permissions.AccessContentsInformation, 'getCategory' )
security.declareProtected(Permissions.AccessContentsInformation, 'getCategory')
def getCategory(self):
"""
Returns the category of the documentation helper
......
......@@ -26,13 +26,13 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from Products.ERP5Type import Permissions
from Products.ERP5Type.Base import Base
from DocumentationHelper import DocumentationHelper, TempObjectLibrary
from DocumentationSection import DocumentationSection
from PortalTypeInstanceDocumentationHelper import PortalTypeInstanceDocumentationHelper
from Products.ERP5Type import Permissions
def getPortalType(uri=''):
"""
......@@ -59,22 +59,64 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getDocumentedObject().Title()
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
_section_list = (
dict(
id='action',
title='Actions',
class_name='PortalTypeActionDocumentationHelper',
),
dict(
id='role',
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):
"""
Returns the type of the documentation helper
"""
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):
"""
Returns the Class of the documentation helper
......@@ -83,150 +125,44 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
return str(klass).split("'")[1]
security.declareProtected( Permissions.AccessContentsInformation, 'getTempInstance' )
def getTempInstance(self, portal_type):
"""
Returns a temporary instance of the given portal_type
"""
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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getAllowedContentTypeList')
def getAllowedContentTypeList(self):
"""
Returns the list of allowed content type of the documentation helper
"""
return getattr(self.getDocumentedObject(), "allowed_content_types", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getAllowedContentTypeURIList' )
def getAllowedContentTypeURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getAllowedContentTypeUriList')
def getAllowedContentTypeUriList(self):
"""
Returns the uri's list of allowed content type of the documentation helper
"""
allowed_content_type_list = self.getAllowedContentTypeList()
return map(lambda x: ('%s/%s' % (self.uri, x)), allowed_content_type_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getHiddenContentTypeList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getHiddenContentTypeList')
def getHiddenContentTypeList(self):
"""
Returns the list of hidden content type of the documentation helper
"""
return getattr(self.getDocumentedObject(), "hidden_content_type_list", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getHiddenContentTypeURIList' )
def getHiddenContentTypeURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getHiddenContentTypeUriList')
def getHiddenContentTypeUriList(self):
"""
Returns the uri's list of hidden content type of the documentation helper
"""
hidden_content_type_list = self.getHiddenContentTypeList()
return map(lambda x: ('%s/%s' % (self.uri, x)), hidden_content_type_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getBaseCategoryList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryList')
def getBaseCategoryList(self):
"""
Returns the list of base category of the documentation helper
"""
return getattr(self.getDocumentedObject(), "base_category_list", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getAcquireLocalRoles' )
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquireLocalRoles')
def getAcquireLocalRoles(self):
"""
Returns the list of allowed content type for the documentation helper
......@@ -237,36 +173,32 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
else:
return 'No'
security.declareProtected( Permissions.AccessContentsInformation, 'getPropertySheetList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getPropertySheetList')
def getPropertySheetList(self):
"""
Returns the list of property sheets for the documentation helper
"""
id = getattr(self.getDocumentedObject(), "id", '')
temp_object = self.getTempInstance(id)
property_sheet = []
for obj in temp_object.property_sheets:
property_sheet.append(obj.__module__.split('.')[-1])
for obj in self.getDocumentedObject().property_sheet_list:
property_sheet.append(obj)
temp_object = self.getTempInstance(self.getId())
property_sheet = [obj.__name__ for obj in temp_object.property_sheets]
property_sheet += self.getDocumentedObject().property_sheet_list
return property_sheet
security.declareProtected( Permissions.AccessContentsInformation, 'getPropertySheetURIList' )
def getPropertySheetURIList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getPropertySheetUriList')
def getPropertySheetUriList(self):
"""
Returns the uri's list of property sheets for the documentation helper
"""
property_sheet_list = self.getPropertySheetList()
return map(lambda x: ('%s/%s.py' % (self.uri, x)), property_sheet_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getGroupList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getGroupList')
def getGroupList(self):
"""
Returns the list of groups for the documentation helper
"""
return getattr(self.getDocumentedObject(), "group_list", [])
security.declareProtected( Permissions.AccessContentsInformation, 'getActionIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getActionIdList')
def getActionIdList(self):
"""
"""
......@@ -276,7 +208,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
action_list.append(action.getId())
return action_list
security.declareProtected( Permissions.AccessContentsInformation, 'getActionItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getActionItemList')
def getActionItemList(self):
"""
"""
......@@ -289,25 +221,14 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
action_list.append((action.getId(), action.title, action.Description(), permission, visible, category))
return action_list
security.declareProtected( Permissions.AccessContentsInformation, 'getActionURIList' )
def getActionURIList(self):
"""
"""
action_item_list = self.getActionItemList()
klass = self.getDocumentedObject().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2], x[3], x[4], x[5]), action_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getActionUriList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getActionUriList')
def getActionUriList(self):
"""
"""
action_id_list = self.getActionIdList()
return map(lambda x: ('%s/%s' % (self.uri, x)), action_id_list)
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):
"""
"""
......@@ -317,7 +238,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
role_list.append(role.Title())
return role_list
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getRoleItemList')
def getRoleItemList(self):
"""
"""
......@@ -326,7 +247,7 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
role_list.append((role.__name__, role.Title(), role.Description()))
return role_list
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleURIList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getRoleURIList')
def getRoleURIList(self):
"""
"""
......@@ -337,41 +258,27 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: ('%s%s' % (uri_prefix, x[0]), x[1], x[2]), role_item_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getRoleUriList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getRoleUriList')
def getRoleUriList(self):
"""
"""
role_id_list = self.getRoleIdList()
return map(lambda x: ('%s/%s' % (self.uri, x)), role_id_list)
return map(lambda x: ('%s?_roles#%s' % (self.uri, x)), role_id_list)
def _getPropertyHolder(self):
from Products.ERP5Type.Base import Base
portal_type = getPortalType(self.uri)
temp_object = self.getTempInstance(portal_type)
dir_temp = dir(temp_object)
return Base.aq_portal_type[(portal_type, temp_object.__class__)]
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' )
def getWorkflowMethodIdList(self, inherited=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList')
def getWorkflowMethodIdList(self):
"""
"""
return self._getPropertyHolder().getWorkflowMethodIdList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodURIList' )
def getWorkflowMethodURIList(self, inherited=1, local=1):
"""
Returns a list of URIs to workflow methods
"""
method_id_list = self.getWorkflowMethodIdList()
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '' #'%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodUriList' )
def getWorkflowMethodUriList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodUriList')
def getWorkflowMethodUriList(self):
"""
Returns a list of URIs to workflow methods
"""
......@@ -384,21 +291,21 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
return map(lambda x: '%s#%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodIdList' )
def getClassMethodIdList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodIdList')
def getClassMethodIdList(self, **kw):
"""
Return a list of tuple (id, method) for every class method
"""
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
return self._getPropertyHolder().getClassMethodIdList(klass, inherited=inherited, local=local)
return self._getPropertyHolder().getClassMethodIdList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodURIList' )
def getClassMethodURIList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodUriList')
def getClassMethodUriList(self, inherited=0, **kw):
"""
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)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
class_name = klass.__name__
......@@ -406,31 +313,18 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' )
def getAccessorMethodIdList(self, inherited=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodIdList')
def getAccessorMethodIdList(self):
"""
"""
return self._getPropertyHolder().getAccessorMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodURIList' )
def getAccessorMethodURIList(self, inherited=1, local=1):
"""
Returns a list of URIs to accessor methods
"""
method_id_list = self.getAccessorMethodIdList(inherited=inherited)
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodUriList' )
def getAccessorMethodUriList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodUriList')
def getAccessorMethodUriList(self):
"""
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)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
class_name = klass.__name__
......
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -42,195 +41,153 @@ class PortalTypeInstanceDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
def getInstance(self):
return self.getPortalObject().restrictedTraverse(self.uri)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getInstance().getTitleOrId()
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
_section_list = (
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):
"""
Returns the type of the documentation helper
"""
return "Portal Type Instance"
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalType')
def getPortalType(self):
"""
"""
return self.getInstance().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
return self.getDocumentedObject().getPortalType()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodItemList')
def getAccessorMethodItemList(self):
"""
"""
return self._getPropertyHolder().getAccessorMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' )
def getAccessorMethodIdList(self, inherited=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodIdList')
def getAccessorMethodIdList(self):
"""
"""
return self._getPropertyHolder().getAccessorMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodURIList' )
def getAccessorMethodURIList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getAccessorMethodUriList')
def getAccessorMethodUriList(self):
"""
Returns a list of URIs to accessor methods
"""
method_id_list = self.getAccessorMethodIdList(inherited=inherited)
klass = self.getInstance().__class__
method_id_list = self.getAccessorMethodIdList()
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), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodItemList')
def getWorkflowMethodItemList(self):
"""
"""
return self._getPropertyHolder().getWorkflowMethodItemList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowObject' )
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowObject')
def getWorkflowObject(self):
"""
"""
return self._getPropertyHolder()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' )
def getWorkflowMethodIdList(self, inherited=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList')
def getWorkflowMethodIdList(self):
"""
"""
return self._getPropertyHolder().getWorkflowMethodIdList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodURIList' )
def getWorkflowMethodURIList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodUriList')
def getWorkflowMethodUriList(self):
"""
Returns a list of URIs to workflow methods
"""
method_id_list = self.getWorkflowMethodIdList()
klass = self.getInstance().__class__
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), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodItemList')
def getActionMethodItemList(self):
"""
"""
return self._getPropertyHolder().getActionMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getActionMethodIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodIdList')
def getActionMethodIdList(self):
"""
"""
return self._getPropertyHolder().getActionMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodItemList' )
def getClassMethodItemList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodItemList')
def getClassMethodItemList(self, **kw):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassMethodItemList(klass, inherited=inherited, local=local)
klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassMethodItemList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodIdList' )
def getClassMethodIdList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodIdList')
def getClassMethodIdList(self, **kw):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassMethodIdList(klass, inherited=inherited, local=local)
klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassMethodIdList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodURIList' )
def getClassMethodURIList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodUriList')
def getClassMethodUriList(self, inherited=0, **kw):
"""
Returns a list of URIs to class methods
"""
method_id_list = self.getClassMethodIdList(inherited=inherited, local=local)
klass = self.getInstance().__class__
method_id_list = self.getClassMethodIdList(inherited=inherited, **kw)
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), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyItemList' )
def getClassPropertyItemList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassPropertyItemList')
def getClassPropertyItemList(self, **kw):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassPropertyItemList(klass, inherited=inherited, local=local)
klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassPropertyItemList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyIdList' )
def getClassPropertyIdList(self, inherited=1, local=1):
security.declareProtected(Permissions.AccessContentsInformation, 'getClassPropertyIdList')
def getClassPropertyIdList(self, **kw):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassPropertyIdList(klass, inherited=inherited, local=local)
klass = self.getDocumentedObject().__class__
return self._getPropertyHolder().getClassPropertyIdList(klass, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getGeneratedPropertyIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getGeneratedPropertyIdList')
def getGeneratedPropertyIdList(self):
"""
"""
security.declareProtected( Permissions.AccessContentsInformation, 'getGeneratedBaseCategoryIdList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getGeneratedBaseCategoryIdList')
def getGeneratedBaseCategoryIdList(self):
"""
"""
......
......@@ -26,12 +26,13 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from Products.CMFCore.utils import getToolByName
# XXX Use lxml instead.
try:
from libxml2 import parseDoc, parserError
import_succeed = 1
......@@ -47,32 +48,28 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Property Sheet"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
security.declareProtected(Permissions.AccessContentsInformation, 'getId')
def getId(self):
"""
Returns the id of the documentation helper
"""
name = getattr(self.getDocumentedObject(), "name", '')
return name.split("/")[-1]
return self.uri.rsplit("/",1)[-1][:-3]
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(self):
"""
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):
"""
Returns the source code the property sheet
......@@ -132,5 +129,4 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper):
return source_code
InitializeClass(PortalTypePropertySheetDocumentationHelper)
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,53 +38,21 @@ class PortalTypeRoleDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Portal Type Role"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getCategoryList')
def getCategoryList(self):
"""
Returns the list of categories for the role
"""
return getattr(self.getDocumentedObject(), "category", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryScript' )
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryScript')
def getBaseCategoryScript(self):
"""
Returns the base category script of the role
......
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......
......@@ -26,12 +26,10 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class ScriptPythonDocumentationHelper(DocumentationHelper):
"""
......@@ -40,38 +38,21 @@ class ScriptPythonDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Script Python"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getParams')
def getParams(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "_params", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' )
security.declareProtected(Permissions.AccessContentsInformation, 'getSourceCode')
def getSourceCode(self):
"""
Returns the source code the script python
......@@ -97,7 +78,7 @@ class ScriptPythonDocumentationHelper(DocumentationHelper):
source_html = portal_transforms.convertTo(mime_type, source_code, mimetype = src_mimetype)
return source_html.getData()
security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' )
security.declareProtected(Permissions.AccessContentsInformation, 'getDefinition')
def getDefinition(self):
"""
Returns the definition of the script with the name of the script and arguments
......
......@@ -26,11 +26,10 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
class SkinFolderDocumentationHelper(DocumentationHelper):
......@@ -40,118 +39,75 @@ class SkinFolderDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
_section_list = (
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' )
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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Skin Folder"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getMetaTypeList')
def getMetaTypeList(self):
meta_type_dict = {}
for file in self.getDocumentedObject().objectValues():
meta_type_dict[file.meta_type] = None
type_list = meta_type_dict.keys()
type_list.sort()
return type_list
return sorted(set(obj.meta_type
for obj in self.getDocumentedObject().objectValues()))
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):
"""
Returns the list of sub-objects ids of the documentation helper
"""
file_list = []
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
return [obj.id for obj in self.getFileValueList(meta_type)]
security.declareProtected(Permissions.AccessContentsInformation, 'getFileItemList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getFileItemList')
def getFileItemList(self, meta_type=None):
"""
Returns the list of sub-objects items of the documentation helper
"""
file_list = []
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,
getattr(file, "title", ""),
getattr(file, "description", ""),
getattr(file, "meta_type", "")))
return file_list
security.declareProtected( Permissions.AccessContentsInformation, 'getFileURIList' )
def getFileURIList(self, meta_type=None):
obj_list = []
for obj in self.getFileValueList(meta_type):
obj = aq_base(obj)
obj_list.append((obj.id,
getattr(obj, "title", ""),
getattr(obj, "description", ""),
getattr(obj, "meta_type", "")))
return obj_list
security.declareProtected(Permissions.AccessContentsInformation, 'getFileUriList')
def getFileUriList(self, meta_type=None):
"""
"""
file_list = self.getFileIdList(meta_type)
base_uri = '/%s/portal_skins/%s' % (self.getPortalObject().id, self.getDocumentedObject().id)
return map(lambda x: ('%s/%s' % (base_uri, x)), file_list)
prefix = self.uri + '/'
return [prefix + obj.id for obj in self.getFileValueList(meta_type)]
def getSectionUriList(self, title, **kw):
return self.getFileUriList(title)
InitializeClass(SkinFolderDocumentationHelper)
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,31 +38,14 @@ class SkinFolderItemDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return getattr(self.getDocumentedObject(), "meta_type", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getContentType')
def getContentType(self):
"""
Returns the title of the documentation helper
......
......@@ -26,12 +26,10 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from DocumentationHelper import DocumentationHelper, getCallableSignatureString
from Products.ERP5Type import Permissions
from AccessorMethodDocumentationHelper import getDefinitionString
class WorkflowMethodDocumentationHelper(DocumentationHelper):
"""
......@@ -40,39 +38,32 @@ class WorkflowMethodDocumentationHelper(DocumentationHelper):
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(), "__doc__", '')
"""
"""
return self.getDocumentedObject().__doc__
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Workflow Method"
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(self):
"""
Returns the title of the documentation helper
"""
# XXX May return _doNothing
return getattr(self.getDocumentedObject(), "_transition_id", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return []
security.declareProtected( Permissions.AccessContentsInformation, 'getDefinition' )
security.declareProtected(Permissions.AccessContentsInformation, 'getDefinition')
def getDefinition(self):
"""
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)
......@@ -26,7 +26,6 @@
#
##############################################################################
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
......@@ -39,31 +38,14 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Z SQL Method"
security.declareProtected(Permissions.AccessContentsInformation, 'getId' )
def getId(self):
"""
Returns the id of the documentation helper
"""
return 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' )
security.declareProtected(Permissions.AccessContentsInformation, 'getSource')
def getSource(self):
"""
Returns the source code of the documentation helper
......@@ -85,35 +67,35 @@ class ZSQLMethodDocumentationHelper(DocumentationHelper):
source_html = portal_transforms.convertTo(mime_type, source_code, mimetype = src_mimetype)
return source_html.getData()
security.declareProtected(Permissions.AccessContentsInformation, 'getConnectionId' )
security.declareProtected(Permissions.AccessContentsInformation, 'getConnectionId')
def getConnectionId(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getDocumentedObject(), "connection_id", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList' )
security.declareProtected(Permissions.AccessContentsInformation, 'getArgumentList')
def getArgumentList(self):
"""
Returns the arguments of the documentation helper
"""
return getattr(self.getDocumentedObject(), "arguments_src", [])
security.declareProtected(Permissions.AccessContentsInformation, 'getClassName' )
security.declareProtected(Permissions.AccessContentsInformation, 'getClassName')
def getClassName(self):
"""
Returns the class name of the documentation helper
"""
return getattr(self.getDocumentedObject(), "class_name_", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getClassFile' )
security.declareProtected(Permissions.AccessContentsInformation, 'getClassFile')
def getClassFile(self):
"""
Returns the class file of the documentation helper
"""
return getattr(self.getDocumentedObject(), "class_file_", '')
security.declareProtected(Permissions.AccessContentsInformation, 'getMaxRows' )
security.declareProtected(Permissions.AccessContentsInformation, 'getMaxRows')
def getMaxRows(self):
"""
Returns the of the documentation helper
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2007-2008 Nexedi SA and Contributors. All Rights Reserved.
......@@ -49,7 +50,6 @@ from WorkflowMethodDocumentationHelper import WorkflowMethodDocumentationHelper
from DCWorkflowStateDocumentationHelper import DCWorkflowStateDocumentationHelper
from DCWorkflowTransitionDocumentationHelper import DCWorkflowTransitionDocumentationHelper
from DCWorkflowVariableDocumentationHelper import DCWorkflowVariableDocumentationHelper
from DCWorkflowPermissionDocumentationHelper import DCWorkflowPermissionDocumentationHelper
from DCWorkflowWorklistDocumentationHelper import DCWorkflowWorklistDocumentationHelper
from DCWorkflowScriptDocumentationHelper import DCWorkflowScriptDocumentationHelper
from SkinFolderDocumentationHelper import SkinFolderDocumentationHelper
......
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