[Zope-CVS] CVS: Packages3/workflow - __init__.py:1.1 configure.zcml:1.1 definition.py:1.1 instance.py:1.1 service.py:1.1

Ulrich Eck ueck@net-labs.de
Sun, 2 Feb 2003 14:21:57 -0500


Update of /cvs-repository/Packages3/workflow
In directory cvs.zope.org:/tmp/cvs-serv25569

Added Files:
	__init__.py configure.zcml definition.py instance.py 
	service.py 
Log Message:
First Round of Rotterdam WorkflowService Migration.

- Interfaces live in zope.app.interfaces.workflow
- WorkflowService tests pass
- ProcessDefinition/Instance are only stubs right now






=== Added File Packages3/workflow/__init__.py ===


=== Added File Packages3/workflow/configure.zcml ===
<zopeConfigure
   xmlns='http://namespaces.zope.org/zope'
   xmlns:service='http://namespaces.zope.org/service'>

<!-- Workflow Service -->

<content class="zope.app.workflow.service.WorkflowService">
  <factory
      id="WorkflowService"
      permission="zope.ManageServices"
      />
  <require
      permission="zope.View"
      interface="zope.app.interfaces.workflow.IWorkflowService"
        attributes="queryConfigurations queryConfigurationsFor
                    listConfigurationNames" />
      />
  <implements 
     interface="zope.app.interfaces.annotation.IAttributeAnnotatable" 
     />
</content>

<serviceType 
  id='Workflows'
  interface='zope.app.interfaces.workflow.IWorkflowService' 
  />



<!-- Workflow Process Definition 
     This is only a generic placeholder for
     future Process Definition implementations
-->

<content class="zope.app.workflow.definition.ProcessDefinition">
  <factory
      id="ProcessDefinition"
      permission="zope.ManageServices"
      />
  <require
      permission="zope.ManageServices"
      interface="zope.app.interfaces.workflow.IProcessDefinition" 
      />
  <implements 
      interface="zope.app.interfaces.annotation.IAttributeAnnotatable" 
      />
</content>


<!-- Process Definition Configuration -->

<content class="zope.app.workflow.service.ProcessDefinitionConfiguration">
  <require
      permission="zope.ManageServices"
      interface=
      "zope.app.interfaces.workflow.IProcessDefinitionConfiguration"
      set_attributes="name componentPath"
      set_schema="zope.app.interfaces.services.interfaces.IPageConfiguration"
      />
  <require
      permission="zope.ManageServices"
      interface="zope.app.interfaces.container.IAddNotifiable"
      />
  <require
      permission="zope.ManageServices"
      interface="zope.app.interfaces.container.IDeleteNotifiable"
      />
</content>


<!-- Process Instance Container -->

<!-- 
<adapter factory="zope.app.workflow.instance.ProcessInstanceContainerAdapter"
         provides="zope.app.interfaces.workflow.IProcessInstanceContainer"
         for="zope.app.interfaces.annotation.IAnnotatable" />

-->

</zopeConfigure>


=== Added File Packages3/workflow/definition.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Implementation of workflow process definition.

$Id: definition.py,v 1.1 2003/02/02 19:21:53 jack-e Exp $
"""
__metaclass__ = type

from persistence import Persistent
from zope.app.interfaces.workflow import IProcessDefinition


class ProcessDefinition(Persistent):

    __doc__ = IProcessDefinition.__doc__
    
    __implements__ = IProcessDefinition

    name = None

    ############################################################
    # Implementation methods for interface
    # zope.app.interfaces.workflow.IProcessDefinition

    def createProcessInstance(self):
        return None

    #
    ############################################################


=== Added File Packages3/workflow/instance.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""Implementation of workflow process instance.

$Id: instance.py,v 1.1 2003/02/02 19:21:53 jack-e Exp $
"""
__metaclass__ = type

from persistence import Persistent
from zope.app.interfaces.workflow import IProcessInstance


# XXX should an Instance be persistent by default ???
class ProcessInstance(Persistent):

    __doc__ = IProcessInstance.__doc__

    __implements__ =  IProcessInstance

    ############################################################
    # Implementation methods for interface
    # zope.app.interfaces.workflow.IProcessInstance

    name = None

    status = None

    processDefinition = None

    #
    ############################################################



=== Added File Packages3/workflow/service.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Workflow service implementation.

Revision information:
$Id: service.py,v 1.1 2003/02/02 19:21:53 jack-e Exp $
"""
__metaclass__ = type

from persistence import Persistent

from zope.proxy.context import ContextMethod
from zope.proxy.context import ContextWrapper

from zope.app.component.nextservice import queryNextService
from zope.app.interfaces.services.configuration \
        import INameComponentConfigurable
from zope.app.services.configuration import NameComponentConfigurable

from zope.app.services.configuration import NamedComponentConfiguration
from zope.app.services.configuration import ConfigurationStatusProperty

from zope.app.interfaces.workflow import IProcessDefinitionConfiguration
from zope.app.interfaces.workflow import IProcessDefinition
from zope.app.interfaces.workflow import IWorkflowService


class ILocalWorkflowService(IWorkflowService, INameComponentConfigurable):
    """A Local WorkflowService.
    """


class WorkflowService(Persistent, NameComponentConfigurable):

    __doc__ = IWorkflowService.__doc__

    __implements__ = ILocalWorkflowService

    ############################################################
    # Implementation methods for interface
    # zope.app.interfaces.workflow.IWorkflowService

    def getProcessDefinitionNames(self):
        'See IWorkflowService'
        definition_names = {}
        for name in self.listConfigurationNames():
            registry = self.queryConfigurations(name)
            if registry.active() is not None:
                definition_names[name] = 0
        service = queryNextService(self, "Workflows")
        if service is not None:
            for name in service.getProcessDefinitionNames():
                definition_names[name] = 0
        return definition_names.keys()

    getProcessDefinitionNames = ContextMethod(getProcessDefinitionNames)


    def getProcessDefinition(self, name):
        'See IWorkflowService'
        pd = self.queryActiveComponent(name)
        if pd is not None:
            return pd
        service = queryNextService(self, "Workflows")
        if service is not None:
            return service.getProcessDefinition(name)
        raise KeyError, name

    getProcessDefinition = ContextMethod(getProcessDefinition)


    def queryProcessDefinition(self, name, default=None):
        'See IWorkflowService'
        try:
            return self.getProcessDefinition(name)
        except KeyError:
            return default

    queryProcessDefinition = ContextMethod(queryProcessDefinition)


    def createProcessInstance(self, definition_name):
        pd = self.getProcessDefinition(definition_name)
        return pd.createProcessInstance()

    createProcessInstance = ContextMethod(createProcessInstance)

    #
    ############################################################




class ProcessDefinitionConfiguration(NamedComponentConfiguration):

    __doc__ = IProcessDefinitionConfiguration.__doc__

    __implements__ = (IProcessDefinitionConfiguration,
                      NamedComponentConfiguration.__implements__)

    status = ConfigurationStatusProperty('Workflows')

    label = "ProcessDefinition"

    def getInterface(self):
        return IProcessDefinition