[Zope-CMF] Re: [Zope-PTK] CMF Dogbowl: workflow Proposal

Kent Polk kent@goathill.org
23 Mar 2001 21:28:28 GMT


On 20 Mar 2001 13:20:00 -0600, Shane Hathaway wrote:
>Kent Polk wrote:
>> 
>> On 19 Mar 2001 20:35:00 -0600, Shane Hathaway wrote:
>> >
>> >> >So, if the default workflow doesn't quite fit, the intention is that you
>> >> >replace or subclass DefaultWorkflow.  That doesn't mean you need to
>> >> >change CMFCore, but until the WorkflowTool is folderish, it does mean
>> >> >you need to make your own WorkflowTool.

>> I changed the id's in RequestWorkflow.py & RequestWorkflowTool.py
>> and the meta_type in RequestWorkflowTool.
>
>I suggest you do not rename portal_workflow.  Its name is part of its
>interface.
>
>The only thing you need in RequestWorkflowTool.py is something like
>this:
>
>class RequestWorkflowTool(WorkflowTool):
>    default_workflow = RequestWorkflow()
>
>Or perhaps more focused:
>
>class RequestWorkflowTool(WorkflowTool):
>    request_workflow = RequestWorkflow()
>
>    def getDefaultChainFor(self, ob):
>        if getattr(ob, '_isPortalContent', 0):
>            if ob.getTypeInfo().id == 'Request':
>                return ('request_workflow',)
>            else:
>                return self._default_chain
>    
>Maybe it's time to just make it into a folder, though...

The problem is that by the time getDefaultChainFor() is called,
it's too late. For example, CatalogTool.catalog_object :
    def catalog_object(self, object, uid):
        # Wraps the object with workflow and accessibility
        # information just before cataloging.
        wf = getattr(self, 'portal_workflow', None)
        if wf is not None:
            vars = wf.getCatalogVariablesFor(object)
        else:
            vars = {}
        w = IndexableObjectWrapper(vars, object)
        ZCatalog.catalog_object(self, w, uid)

grabs the generic wf before getDefaultChainFor() is even called,
wf.getCatalogVariablesFor() should call the request_workflow,
but doesn't.