[Grok-dev] Question regarding hurry.workflow

Tim Cook timothywayne.cook at gmail.com
Fri May 8 18:37:33 EDT 2009


Hi Sebastian,

WOW! thanks for this.  I will havee to do some testing with this but it
looks great so far.  It'll likely be the first part of June before I can
get serious with it though (I have other infrastructure to finish
first).

Cheers,
Tim


On Thu, 2009-05-07 at 21:02 +0200, Sebastian Ware wrote:
> Hi Tim (and anybody else interested in multiple workflow support)!
> 
> I have made a small experiment adding multiple workflow support to  
> hurry.workflow using named utilities and namned adapters. It requires  
> a "default" unnamed workflow to support versions. Maybe you could look  
> at this and see if it might be useful.
> 
> The general idea is that you have an unnamed default workflow. Then  
> you can add an arbitrary nr of named workflows. These can be set up  
> with the same transitions as the default workflow or have other sets  
> of transitions. I really just wanted to create a very light weight  
> solution with a minimum of code changes.
> 
> I define my workflows like this:
> 
> #
> # Default workflow (without name)
> 
> class Workflow(grok.GlobalUtility, workflow.Workflow):
>      grok.provides(IWorkflow)
> 
>      def __init__(self):
>          super(Workflow, self).__init__(create_workflow())
> 
> class WorkflowState(grok.Adapter, workflow.WorkflowState):
>      grok.context(IProtonObject)
>      grok.provides(interfaces.IWorkflowState)
> 
> class WorkflowInfo(grok.Adapter, workflow.WorkflowInfo):
>      grok.context(IProtonObject)
>      grok.provides(interfaces.IWorkflowInfo)
> 
> #
> # Named workflow (called "sebastian")
> 
> class SpecialWorkflow(grok.GlobalUtility, workflow.Workflow):
>      grok.name('sebastian')
>      grok.provides(IWorkflow)
> 
>      def __init__(self):
>          super(SpecialWorkflow, self).__init__(create_workflow())
> 
> class SpecialState(grok.Adapter, workflow.WorkflowState):
>      grok.context(IProtonObject)
>      grok.provides(interfaces.IWorkflowState)
>      grok.name("sebastian")
>      workflow_name = "sebastian"
> 
> class SpecialInfo(grok.Adapter, workflow.WorkflowInfo):
>      grok.context(IProtonObject)
>      grok.provides(interfaces.IWorkflowInfo)
>      grok.name("sebastian")
>      workflow_name = "sebastian"
> 
> #
> # Getting a workflow utility
> from zope.component import getUtility
> default_wu = getUtility(IWorkflow)
> named_wu = getUtility(IWorkflow, "sebastian")
> 
> #
> # Manipulating an object
> from zope.component import getAdapter
> default_wi = IWorkflowInfo(item)
> named_wi = getAdapter(item, IWorkflowInfo, name="sebastian")
> 
> 
> Attached is the updated hurry.workflow.workflow(.py) file. I also  
> added the attribute "workflow_name" to interface.py for both  
> IWorkflowInfo and IWorkflowState.
> 
> 
> 
> Mvh Sebastian
> 
> 
> 3 maj 2009 kl. 00.43 skrev Tim Cook:
> >
> > Since you were discussing ore.workflow and it having multiple  
> > workflows
> > I decided to take a look.
> >
> > I will soon need this functionality.
> 
-- 
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook 
Skype ID == timothy.cook 
**************************************************************
*You may get my Public GPG key from  popular keyservers or   *
*from this link http://timothywayne.cook.googlepages.com/home*
**************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20090508/d09d4f81/attachment.bin 


More information about the Grok-dev mailing list