Commit 1b76e57e authored by Mayoro Diagne's avatar Mayoro Diagne

using getattr to get co_varnames; using unrestrictedTraverse instead of...

using getattr to get co_varnames; using unrestrictedTraverse instead of resolveCtagegory to avoid warning in case of unexisting category

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22052 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 477a2236
......@@ -34,10 +34,12 @@ 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 == None:
if obj is None:
return ""
else:
fc_var_names = obj.func_code.co_varnames
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':
......
......@@ -31,6 +31,7 @@ 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):
"""
......@@ -44,7 +45,8 @@ class DCWorkflowPermissionDocumentationHelper(DocumentationHelper):
security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
def getDescription(self):
return getattr(self.getDocumentedObject(), "description", "")
#return getattr(self.getDocumentedObject(), "description", "")
return ""
security.declareProtected(Permissions.AccessContentsInformation, 'getType' )
def getType(self):
......
......@@ -103,8 +103,6 @@ class DocumentationHelper(Implicit):
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)
self.getTempInstance = TempObjectLibrary(self.getPortalObject().portal_classes)
temp_object = self.getTempInstance(portal_type)
if '/' not in method:
......@@ -131,17 +129,14 @@ class DocumentationHelper(Implicit):
elif '/' in self.uri and '#' not in self.uri:
# URI refers to a portal object
# and is a relative URL
try:
documented_object = self.getPortalObject().portal_categories.resolveCategory(self.uri)
except:
documented_object = None
documented_object = self.getPortalObject().portal_categories.unrestrictedTraverse(self.uri, None)
if documented_object is None:
documented_object = self.getPortalObject().unrestrictedTraverse(self.uri)
documented_object = self.getPortalObject().unrestrictedTraverse(self.uri, None)
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)
parent_object = self.getPortalObject().unrestrictedTraverse(base_url, None)
object_list = getattr(parent_object, type, None)
documented_object = None
if object_list is not None:
......@@ -150,9 +145,9 @@ class DocumentationHelper(Implicit):
documented_object = obj
else:
url, method = self.uri.split('#')
documented_object = self.getPortalObject().unrestrictedTraverse(url)
documented_object = self.getPortalObject().unrestrictedTraverse(url, None)
if '/' not in method:
documented_object = self.getPortalObject().unrestrictedTraverse(url)
documented_object = self.getPortalObject().unrestrictedTraverse(url, None)
documented_object = getattr(documented_object, method, None)
else:
path_method = method.split('/')
......@@ -169,7 +164,7 @@ class DocumentationHelper(Implicit):
import Products
documented_object = Products
for key in module_list[1:]:
documented_object = getattr(documented_object, key)
documented_object = getattr(documented_object, key, None)
else:
raise NotImplemented
#fp, pathname, description = imp.find_module(base_module)
......
......@@ -62,7 +62,7 @@ class PortalTypePropertySheetDocumentationHelper(DocumentationHelper):
"""
Returns the title of the documentation helper
"""
return getattr(self.etDocumentedObject(), "name", '')
return getattr(self.getDocumentedObject(), "name", '')
security.declareProtected( Permissions.AccessContentsInformation, 'getSourceCode' )
def getSourceCode(self):
......
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