[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Workflow - IWorkflowService.py:1.1.2.1 WorkflowService.py:1.1.2.1
   
    Vincenzo Di Somma
     
    e.disomma@icube.it
       
    Wed, 6 Mar 2002 05:49:55 -0500
    
    
  
Update of /cvs-repository/Zope3/lib/python/Zope/App/Workflow
In directory cvs.zope.org:/tmp/cvs-serv4731
Added Files:
      Tag: Zope-3x-branch
	IWorkflowService.py WorkflowService.py 
Log Message:
Workflow Service added
=== Added File Zope3/lib/python/Zope/App/Workflow/IWorkflowService.py ===
"""
    Interfaces for Workflow Service.
"""
from Interface import Interface
class IWorkflowService( Interface ):
    """
        Interface for workflow service.
    """
    def listEngine():
        """
           Return the list of engine and their interfaces
        """
        pass
    def getEngine(IWorkflowEngine):
        """
           Return a workflow engine giving its interface
        """
        pass
    def addEngine(WorkflowEngine):
        """
           Add a workflow engine
        """
    def removeEngine(WorkflowEngine):
        """
           Remove Workflow engine from the system
        """
        pass
    def listWorkflowEngineActions():
        """
           Return an aggregation of the actions provided
           by the present engines
        """
    
=== Added File Zope3/lib/python/Zope/App/Workflow/WorkflowService.py ===
from Zope.App.Workflow.IWorkflowService import IWorkflowService
class WorkflowService:
    __implements__ =  IWorkflowService
    ############################################################
    # Implementation methods for interface
    # Zope.App.Workflow.IWorkflowService
    engines = ()
    def removeEngine(self, engine):
        '''See interface IWorkflowService'''
        self.engines = tuple(filter(lambda x: x != engine, self.engines))
    def listWorkflowEngineActions(self):
        '''See interface IWorkflowService'''
        result = []
        for engine in self.engines:
            result.extend(engine.listActions())
        return result
    
    def listEngine(self):
        '''See interface IWorkflowService'''
        return self.engines
    def addEngine(self, engine):
        '''See interface IWorkflowService'''
        self.engines = self.engines + (engine,)
    def getEngine(self, interface):
        '''See interface IWorkflowService'''
        result = []
        for engine in self.engines:
            if interface.isImplementedBy(engine):
                result.append(engine)
        return result
    
    #
    ############################################################