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
......
......@@ -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)
##############################################################################
#
# 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):
security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionList')
def getTransitionList(self):
"""
Returns a list of documentation sections
Returns list of possible transitions from this state
"""
return []
return self.getDocumentedObject().transitions
security.declareProtected( Permissions.AccessContentsInformation, 'getTransitionList' )
def getTransitionList(self):
def getPermissionsOfRole(self, role):
"""
Returns list of possible transitions from this state
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
"""
return getattr(self.getDocumentedObject(), "transitions", [])
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' )
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", '')
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(
_section_list = (
dict(
id='business_template',
title='Business Template',
class_name='BusinessTemplateDocumentationHelper',
uri_list=self.getBusinessTemplateUriList(),
),
])
)
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getType')
def getType(self):
"""
Returns the description of the documentation helper
Returns the type of the documentation helper
"""
return getattr(self.getDocumentedObject(), "description", '')
return "ERP5 Site"
security.declareProtected( Permissions.AccessContentsInformation, 'getBusinessTemplateItemList' )
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')
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,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,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
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(
_section_list = (
dict(
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(
),
dict(
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(
),
dict(
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(
),
dict(
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()))
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' )
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