Commit 883eed2d authored by Mayoro Diagne's avatar Mayoro Diagne

adding new documentation class for base categories: BaseCategoryDocumentationHelper

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23722 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d34e8c98
##############################################################################
#
# 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 DocumentationSection import DocumentationSection
from Products.ERP5Type import Permissions
class BaseCategoryDocumentationHelper(DocumentationHelper):
"""
Provides access to all documentation information
of a portal type instance.
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def __init__(self, uri):
self.uri = uri
def getInstance(self):
return self.getPortalObject().restrictedTraverse(self.uri)
# API Implementation
security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
def getTitle(self):
"""
Returns the title of the documentation helper
"""
return self.getInstance().getTitleOrId()
security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
def getDescription(self):
"""
Returns the title of the documentation helper
"""
return getattr(self.getInstance(), 'description', '')
security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
def getType(self):
"""
Returns the type of the documentation helper
"""
return "Base Category"
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionAppendValue')
def getAcquisitionAppendValue(self):
"""
Returns the value of acquisition append value of the documented base category
"""
return getattr(self.getInstance(), 'acquisition_append_value', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionMaskValue')
def getAcquisitionMaskValue(self):
"""
Returns the value of acquisition mask value of the documented base category
"""
return getattr(self.getInstance(), 'acquisition_mask_value', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionCopyValue')
def getAcquisitionCopyValue(self):
"""
Returns the value of acquisition copy value of the documented base category
"""
return getattr(self.getInstance(), 'acquisition_copy_value', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionSyncValue')
def getAcquisitionSyncValue(self):
"""
Returns the value of acquisition sync value of the documented base category
"""
return getattr(self.getInstance(), 'acquisition_sync_value', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionBaseCategoryList')
def getAcquisitionBaseCategoryList(self):
"""
Returns the acquisition base categories of the documented base category
"""
return getattr(self.getInstance(), 'acquisition_base_category', [])
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionObjectIds')
def getAcquisitionObjectIds(self):
"""
Returns the acquisitions ids of the documented base category
"""
return getattr(self.getInstance(), 'acquisition_object_id', [])
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionPortalType')
def getAcquisitionPortalType(self):
"""
Returns the acquisitions ids of the documented base category
"""
return getattr(self.getInstance(), 'acquisition_portal_type', '')
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquisitionCategoryType')
def getAcquisitionCategoryType(self):
"""
Returns the acquisitions ids of the documented base category
"""
return getattr(self.getInstance(), 'category_type', [])
security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
def getSectionList(self):
"""
Returns a list of documentation sections
"""
return [
DocumentationSection(
id='workflow_method',
title='Workflow Method',
class_name='WorkflowMethodDocumentationHelper',
uri_list=self.getWorkflowMethodURIList(inherited=0),
),
DocumentationSection(
id='accessor',
title='Accessor',
class_name='AccessorMethodDocumentationHelper',
uri_list=self.getAccessorMethodURIList(inherited=0),
),
DocumentationSection(
id='class_method',
title='Class Methods',
class_name='ClassMethodDocumentationHelper',
uri_list=self.getClassMethodURIList(inherited=0),
).__of__(self.getInstance()),
]
# Specific methods
security.declareProtected( Permissions.AccessContentsInformation, 'getPortalType' )
def getPortalType(self):
"""
"""
return self.getInstance().getPortalType()
def _getPropertyHolder(self):
from Products.ERP5Type.Base import Base
property_holder = None
key = (self.getPortalType(), self.getInstance().__class__)
if not(Base.aq_portal_type.has_key(key)):
self.getInstance().initializePortalTypeDynamicProperties()
property_holder = Base.aq_portal_type[(self.getPortalType(), self.getInstance().__class__)]
return property_holder
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodItemList' )
def getAccessorMethodItemList(self):
"""
"""
return self._getPropertyHolder().getAccessorMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' )
def getAccessorMethodIdList(self, inherited=1):
"""
"""
return self._getPropertyHolder().getAccessorMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodURIList' )
def getAccessorMethodURIList(self, inherited=1, local=1):
"""
Returns a list of URIs to accessor methods
"""
method_id_list = self.getAccessorMethodIdList(inherited=inherited)
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodItemList' )
def getWorkflowMethodItemList(self):
"""
"""
return self._getPropertyHolder().getWorkflowMethodItemList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowObject' )
def getWorkflowObject(self):
"""
"""
return self._getPropertyHolder()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList' )
def getWorkflowMethodIdList(self, inherited=1):
"""
"""
return self._getPropertyHolder().getWorkflowMethodIdList()
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodURIList' )
def getWorkflowMethodURIList(self, inherited=1, local=1):
"""
Returns a list of URIs to workflow methods
"""
method_id_list = self.getWorkflowMethodIdList()
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '' #'%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getActionMethodItemList' )
def getActionMethodItemList(self):
"""
"""
return self._getPropertyHolder().getActionMethodItemList()
security.declareProtected( Permissions.AccessContentsInformation, 'getActionMethodIdList' )
def getActionMethodIdList(self):
"""
"""
return self._getPropertyHolder().getActionMethodIdList()
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodItemList' )
def getClassMethodItemList(self, inherited=1, local=1):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassMethodItemList(klass, inherited=inherited, local=local)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodIdList' )
def getClassMethodIdList(self, inherited=1, local=1):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassMethodIdList(klass, inherited=inherited, local=local)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassMethodURIList' )
def getClassMethodURIList(self, inherited=1, local=1):
"""
Returns a list of URIs to class methods
"""
method_id_list = self.getClassMethodIdList(inherited=inherited, local=local)
klass = self.getInstance().__class__
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
return map(lambda x: '%s%s' % (uri_prefix, x), method_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyItemList' )
def getClassPropertyItemList(self, inherited=1, local=1):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassPropertyItemList(klass, inherited=inherited, local=local)
security.declareProtected( Permissions.AccessContentsInformation, 'getClassPropertyIdList' )
def getClassPropertyIdList(self, inherited=1, local=1):
"""
Return a list of tuple (id, method) for every class method
"""
klass = self.getInstance().__class__
return self._getPropertyHolder().getClassPropertyIdList(klass, inherited=inherited, local=local)
InitializeClass(BaseCategoryDocumentationHelper)
...@@ -60,5 +60,6 @@ from ScriptPythonDocumentationHelper import ScriptPythonDocumentationHelper ...@@ -60,5 +60,6 @@ from ScriptPythonDocumentationHelper import ScriptPythonDocumentationHelper
from ERP5FormDocumentationHelper import ERP5FormDocumentationHelper from ERP5FormDocumentationHelper import ERP5FormDocumentationHelper
from PageTemplateDocumentationHelper import PageTemplateDocumentationHelper from PageTemplateDocumentationHelper import PageTemplateDocumentationHelper
from ZSQLMethodDocumentationHelper import ZSQLMethodDocumentationHelper from ZSQLMethodDocumentationHelper import ZSQLMethodDocumentationHelper
from BaseCategoryDocumentationHelper import BaseCategoryDocumentationHelper
from ERP5SiteDocumentationHelper import ERP5SiteDocumentationHelper from ERP5SiteDocumentationHelper import ERP5SiteDocumentationHelper
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