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

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21607 20353a03-c40f-0410-a6d1-a30d3c3de9de

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