[Grok-dev] Question regarding hurry.workflow

Sebastian Ware sebastian at urbantalk.se
Thu Apr 16 08:39:33 EDT 2009


I apologize if this question is a bit on the fringe. I would like to  
have multiple workflows in hurry.workflow. One could do this by adding  
states that aren't "connected" but I would rather do it by registering  
the workflow as a named global utility rather than the unnamed global  
utility that is used now. Is this a bad idea? Have I misunderstood  
something?

If it is a good idea, how can I contribute code and a test to the  
distribution?

This is my idea. To register a hurry.workflow workflow in Grok I do:

class Workflow(grok.GlobalUtility, workflow.Workflow):
     grok.provides(IWorkflow)

     def __init__(self):
         super(Workflow, self).__init__(create_workflow())

In order to create the workflow as a named utility I need to add:

     grok.name('a_named_workflow')

The method zope.component.getUtility() is used to look up the workflow  
and it takes the name parameter, which defaults to name='':

    def getUtility(interface, name='', context=None):

Could one not update hurry.workflow to support multiple workflows by  
means of naming the registered utility by changing the following:

class WorkflowInfo(object):
     implements(IWorkflowInfo)

     def __init__(self, context):
         self.context = context

     def fireTransition(self, transition_id, comment=None,  
side_effect=None,
                        check_security=True):
         state = IWorkflowState(self.context)
         wf = zapi.getUtility(IWorkflow)

...to...

class WorkflowInfo(object):
     implements(IWorkflowInfo)

     def __init__(self, context, name=''):
         self.context = context
	self.workflow_name = name

     def fireTransition(self, transition_id, comment=None,  
side_effect=None,
                        check_security=True):
         state = IWorkflowState(self.context)
         wf = zapi.getUtility(IWorkflow, self.workflow_name)

Mvh Sebastian


More information about the Grok-dev mailing list