[Erp5-report] r18605 - /erp5/trunk/products/ERP5Type/DocumentationHelper.py

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Jan 5 23:40:30 CET 2008


Author: jp
Date: Sat Jan  5 23:40:30 2008
New Revision: 18605

URL: http://svn.erp5.org?rev=18605&view=rev
Log:
Moved code to separate files.

Modified:
    erp5/trunk/products/ERP5Type/DocumentationHelper.py

Modified: erp5/trunk/products/ERP5Type/DocumentationHelper.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/DocumentationHelper.py?rev=18605&r1=18604&r2=18605&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/DocumentationHelper.py (original)
+++ erp5/trunk/products/ERP5Type/DocumentationHelper.py Sat Jan  5 23:40:30 2008
@@ -8,718 +8,22 @@
 from Products.ERP5Type.Base import WorkflowMethod
 from Products.ERP5Type import Permissions
 
-class DocumentationSection(Implicit):
-
-  security = ClassSecurityInfo()
-  security.declareObjectProtected(Permissions.AccessContentsInformation)
-
-  def __init__(self, id, title, class_name, uri_list):
-    self.id = id
-    self.title = title
-    self.class_name = class_name
-    self.uri_list = uri_list
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getClassName')
-  def getClassName(self):
-    return self.class_name
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getURIList')
-  def getURIList(self):
-    return self.uri_list
-
-  # more API needed XXX
-
-InitializeClass(DocumentationSection)
-
-class DocumentationHelper(Implicit):
-  """
-    Example URIs
-
-    person_module/23
-    person_module/23#title
-    person_module/23#getTitle
-    portal_worklows/validation_workflow
-    portal_worklows/validation_workflow/states/draft
-    portal_worklows/validation_workflow/states/draft#title
-    Products.ERP5Type.Document.Person.notify
-    Products.ERP5Type.Document.Person.isRAD
-    portal_types/Person
-    portal_types/Person/actions#view
-  """
-  security = ClassSecurityInfo()
-  security.declareObjectProtected(Permissions.AccessContentsInformation)
-
-  # Methods to override
-  def __init__(self, uri):
-    self.uri = uri
-
-  def getDocumentedObject(self):
-    if '/' in self.uri and '#' not in self.uri:
-      # URI refers to a portal object
-      # and is a relative URL
-      documented_object = self.getPortalObject().portal_categories.resolveCategory(self.uri)  
-    elif '/' in self.uri and '#' in self.uri:
-      url, method = self.uri.split('#') 
-      # if / in method, method's not an acessor but a workflow method
-      documented_object = self.getPortalObject().unrestrictedTraverse(url)
-      if '/' not in method:
-        documented_object = self.getPortalObject().unrestrictedTraverse(url)
-        documented_object = getattr(documented_object, method, None)
-      else:
-        wf_url = 'portal_workflow/%s' % method
-        documented_object = self.getPortalObject().unrestrictedTraverse(wf_url)
-    else:
-      # URI refers to a python class / method
-      import imp
-      module_list = self.uri.split('.')
-      base_module = module_list[0]
-      if base_module == 'Products':
-        # For now, we do not even try to import
-        # or locate objects which are not in Products
-        import Products
-        documented_object = Products
-        for key in module_list[1:]:
-          LOG('loop in module_list', 0, repr(documented_object))
-          documented_object = getattr(documented_object, key)
-      else:
-        raise NotImplemented
-        #fp, pathname, description = imp.find_module(base_module)
-        #documented_object = imp.load_module(fp, pathname, description)
-
-    return documented_object
-
-  def getTitle(self):
-    """
-    Returns the title of the documentation helper
-    (ex. class name)
-    """
-    raise NotImplemented
-
-  def getType(self):
-    """
-    Returns the type of the documentation helper
-    (ex. Class, float, string, Portal Type, etc.)
-    """
-    raise NotImplemented
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getSectionList')
-  def getSectionList(self):
-    """
-    Returns a list of documentation sections
-    """
-    raise NotImplemented
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getURI')
-  def getURI(self):
-    """
-    Returns a URI to later access this documentation
-    from portal_classes
-    """
-    return self.uri
-
-  # Generic methods which all subclasses should inherit
-  security.declareProtected(Permissions.AccessContentsInformation, 'getClassName')
-  def getClassName(self):
-    """
-    Returns our own class name
-    """
-    return self.__class__.__name__
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'view')
-  def view(self):
-    """
-    Renders the documentation with a standard form
-    ex. PortalTypeInstanceDocumentationHelper_view
-    """
-    return getattr(self, '%s_view' % self.getClassName())()
-
-  security.declareProtected(Permissions.AccessContentsInformation, '__call__')
-  def __call__(self):
-    return self.view()
-
-InitializeClass(DocumentationHelper)
-
-class PortalTypeInstanceDocumentationHelper(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, 'getType' )
-  def getType(self):
-    """
-    Returns the type of the documentation helper
-    """
-    return "Portal Type Instance"
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
-  def getSectionList(self):
-    """
-    Returns a list of documentation sections
-    """
-    return [
-      #DocumentationSection(
-        #id='instance_property',
-        #title='Instance Properties',
-        #class_name='InstancePropertyDocumentationHelper',
-        #uri_list=self.getClassPropertyURIList(),
-      #),
-      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
-    return Base.aq_portal_type[(self.getPortalType(), self.getInstance().__class__)]
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodItemList' )
-  def getAccessorMethodItemList(self):
-    """
-    """
-    return self._getPropertyHolder().getAccessorMethodItemList()
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodIdList' )
-  def getAccessorMethodIdList(self):
-    """
-    """
-    return self._getPropertyHolder().getAccessorMethodIdList()
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getAccessorMethodURIList' )
-  def getAccessorMethodURIList(self, inherited=1, local=1):
-    """
-    Returns a list of URIs to accessor methods
-    """
-    method_id_list = self.getAccessorMethodIdList(inherited=inherited, 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, '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):
-    """
-    """
-    return self._getPropertyHolder().getWorkflowMethodIdList()    
-
-  def getWorkflowMethodURIList(self, inherited=1, local=1):
-    """
-    Returns a list of URIs to workflow  methods
-    """
-    method_id_list = self.getWorkflowMethodIdList(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, '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)
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getGeneratedPropertyIdList' )
-  def getGeneratedPropertyIdList(self):
-    """
-    """
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getGeneratedBaseCategoryIdList' )
-  def getGeneratedBaseCategoryIdList(self):
-    """
-    """
-
-InitializeClass(PortalTypeInstanceDocumentationHelper)
-
-class PortalDocumentationHelper(DocumentationHelper):
-  """
-  """
-
-class ClassDocumentationHelper(DocumentationHelper):
-  """
-  """
-
-class AccessorDocumentationHelper(DocumentationHelper):
-  """
-  """
-
-class ClassMethodDocumentationHelper(DocumentationHelper):
-  """
-    Provides documentation about a class method
-  """
-  security = ClassSecurityInfo()
-  security.declareObjectProtected(Permissions.AccessContentsInformation)
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
-  def getDescription(self):
-    return self.getDocumentedObject().__doc__
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
-  def getType(self):
-    """
-    Returns the type of the documentation helper
-    """
-    return "Class Method"
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
-  def getTitle(self):
-    """
-    Returns the type of the documentation helper
-    """
-    return self.getDocumentedObject().__name__
-
-InitializeClass(ClassMethodDocumentationHelper)
-
-class AccessorMethodDocumentationHelper(DocumentationHelper):
-  """
-    Provides documentation about an accessor
-  """
-  security = ClassSecurityInfo()
-  security.declareObjectProtected(Permissions.AccessContentsInformation)
-
-  def __init__(self, uri):
-    self.uri = uri
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getDescription')
-  def getDescription(self):
-    return self.getDocumentedObject().__doc__
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
-  def getType(self):
-    """
-    Returns the type of the documentation helper
-    """
-    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__
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getArgCount' )
-  def getArgCount(self):
-    """
-    Returns the number of args of the accessor
-    """
-    return self.getDocumentedObject().func_code.co_argcount
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getVarNames' )
-  def getVarNames(self):
-    """
-    Returns the list of args of the accessor
-    """
-    return self.getDocumentedObject().func_code.co_varnames
-
-
-InitializeClass(AccessorMethodDocumentationHelper)
-
-class CallableDocumentationHelper(DocumentationHelper):
-  """
-  """
-
-class InstancePropertyDocumentationHelper(DocumentationHelper):
-  """
-  """
-
-class PropertyDocumentationHelper(DocumentationHelper):
-  """
-  """
-
-class WorkflowMethodDocumentationHelper(DocumentationHelper):
-  """
-    Provides documentation about a workflow method
-  """
-  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' )
-  def getType(self):
-    """
-    Returns the type of the documentation helper
-    """
-    return self.getDocumentedObject().__module__
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getTitle' )
-  def getTitle(self):
-    """
-    Returns the title of the documentation helper
-    """
-    return self.getDocumentedObject().__dict__['title']
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationState' )
-  def getDestinationState(self):
-    """
-    Returns the destination_state of the transition workflow method
-    """
-    return self.getDocumentedObject().__dict__['new_state_id']
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getTriggerType' )
-  def getTriggerType(self):
-    """
-    Returns the trigger type of the workflow method
-    """
-    TT = ['Automatic','Initiated by user action','Initiated by WorkflowMethod']
-    TT_id = self.getDocumentedObject().__dict__['trigger_type']
-    return TT[TT_id]
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getLocalRoles' )
-  def getLocalRoles(self):
-    """
-    Returns the local roles of the workflow method
-    """
-    return self.getDocumentedObject().__ac_local_roles__
-
-  security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableStateIds' )
-  def getAvailableStateIds(self):
-    """
-    Returns available states in the workflow
-    """
-    return self.getDocumentedObject().getAvailableStateIds()
-
-InitializeClass(WorkflowMethodDocumentationHelper)
-
-class DCWorkflowDocumentationHelper(DocumentationHelper):
-  """
-    Provides access to all documentation information
-    of a workflow.
-  """
-
-  security = ClassSecurityInfo()
-  security.declareObjectProtected(Permissions.AccessContentsInformation)
-
-  # API Implementation
-  security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
-  def getTitle(self):
-    """
-    Returns the title of the documentation helper
-    """
-    return self.getDocumentedObject().getTitleOrId()
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
-  def getType(self):
-    """
-    Returns the type of the documentation helper
-    """
-    return "DC Workflow"
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
-  def getSectionList(self):
-    """
-    Returns a list of documentation sections
-    """
-    return map(lambda x: x.__of__(self), [
-      DocumentationSection(
-        id='state',
-        title='Workflow States',
-        class_name='DCWorkflowStateDocumentationHelper',
-        uri_list=self.getStateURIList(),
-      ),
-      DocumentationSection(
-        id='transition',
-        title='Workflow Transitions',
-        class_name='DCWorkflowTransitionDocumentationHelper',
-        uri_list=self.getStateURIList(),
-      ),
-      DocumentationSection(
-        id='variable',
-        title='Workflow Variables',
-        class_name='DCWorkflowVariableDocumentationHelper',
-        uri_list=self.getVariableURIList(),
-      ),
-      DocumentationSection(
-        id='variable',
-        title='Workflow Permissions',
-        class_name='PermissionDocumentationHelper',
-        uri_list=self.getPermissionURIList(),
-      ),
-    ])
-
-  # Specific methods
-  security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
-  def getDescription(self):
-    """
-    Returns the title of the documentation helper
-    """
-    raise NotImplemented
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' )
-  def getVariableURIList(self):
-    """
-    """
-    raise NotImplemented
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getStateURIList' )
-  def getStateURIList(self):
-    """
-    """
-    raise NotImplemented
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getVariableURIList' )
-  def getVariableURIList(self):
-    """
-    """
-    raise NotImplemented
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getPermissionURIList' )
-  def getPermissionURIList(self):
-    """
-    """
-    raise NotImplemented
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageURL' )
-  def getGraphImageURL(self):
-    """
-      Returns a URL to a graphic representation of the workflow
-    """
-    raise NotImplemented
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getGraphImageData' )
-  def getGraphImageData(self):
-    """
-      Returns the graphic representation of the workflow as a PNG file
-    """
-    raise NotImplemented
-
-InitializeClass(DCWorkflowDocumentationHelper)
-
-class BusinessTemplateDocumentationHelper(DocumentationHelper):
-  """
-    Provides access to all documentation information
-    of a business template.
-  """
-
-  security = ClassSecurityInfo()
-  security.declareObjectProtected(Permissions.AccessContentsInformation)
-
-  # API Implementation
-  security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
-  def getTitle(self):
-    """
-    Returns the title of the documentation helper
-    """
-    return self.getDocumentedObject().getTitleOrId()
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
-  def getType(self):
-    """
-    Returns the type of the documentation helper
-    """
-    return "Business Template"
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
-  def getSectionList(self):
-    """
-    Returns a list of documentation sections
-    """
-    return map(lambda x: x.__of__(self), [
-      DocumentationSection(
-        id='portal_type',
-        title='Portal Types',
-        class_name='PortalTypeDocumentationHelper',
-        uri_list=self.getPortalTypeURIList(),
-      ),
-      DocumentationSection(
-        id='workflow',
-        title='Workflows',
-        class_name='DCWorkflowDocumentationHelper',
-        uri_list=self.getDCWorkflowURIList(),
-      ),
-      DocumentationSection(
-        id='interaction',
-        title='Interaction Workflows',
-        class_name='InteractionWorkflowStateDocumentationHelper',
-        uri_list=self.getInteractionWorkflowURIList(),
-      ),
-      DocumentationSection(
-        id='skin_folder',
-        title='Skin Folders',
-        class_name='SkinFolderDocumentationHelper',
-        uri_list=self.getSkinFolderURIList(),
-      ),
-    ])
-
-  # Specific methods
-  security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
-  def getDescription(self):
-    """
-    Returns the title of the documentation helper
-    """
-    raise NotImplemented
-
-
-InitializeClass(BusinessTemplateDocumentationHelper)
-
-
-class PortalTypeDocumentationHelper(DocumentationHelper):
-  """
-    Provides access to all documentation information
-    of a portal type. Accessors and methods are documented
-    by generating a temporary instance which provides
-    an access to the property holder and allows
-    reusing PortalTypeInstanceDocumentationHelper
-  """
-
-  security = ClassSecurityInfo()
-  security.declareObjectProtected(Permissions.AccessContentsInformation)
-
-  # API Implementation
-  security.declareProtected( Permissions.AccessContentsInformation, 'getTitle' )
-  def getTitle(self):
-    """
-    Returns the title of the documentation helper
-    """
-    return self.getDocumentedObject().getTitleOrId()
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getType' )
-  def getType(self):
-    """
-    Returns the type of the documentation helper
-    """
-    return "Portal Type"
-
-  security.declareProtected( Permissions.AccessContentsInformation, 'getSectionList' )
-  def getSectionList(self):
-    """
-    Returns a list of documentation sections
-    """
-    return map(lambda x: x.__of__(self), [
-      DocumentationSection(
-        id='action',
-        title='Actions',
-        class_name='ActionDocumentationHelper',
-        uri_list=self.getActionURIList(),
-      ),
-      DocumentationSection(
-        id='local_role',
-        title='Local Role Definitions',
-        class_name='LocalRoleDefinitionDocumentationHelper',
-        uri_list=self.getDCWorkflowURIList(),
-      ),
-      # XXX - add here all sections of a portal type instance
-    ])
-
-  # Specific methods
-  security.declareProtected( Permissions.AccessContentsInformation, 'getDescription' )
-  def getDescription(self):
-    """
-    Returns the title of the documentation helper
-    """
-    raise NotImplemented
-
-
-InitializeClass(PortalTypeDocumentationHelper)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 




More information about the Erp5-report mailing list