[Product-Developers] Re: Getting workflow policy for checked out object using plone.app.iterate

Maurits van Rees m.van.rees at zestsoftware.nl
Wed Mar 4 08:24:55 UTC 2009


Mike Revoir, on 2009-03-03:
>
> I'm trying to solve a problem that I'm having when I use a custom checkout
> workflow that does not use workflow state names that are part of the object
> types workflow policy. For example, if Documents use the
> simple_publishing_workflow and my checkout_work has states checked_out and
> awaiting_checkin (for simplicity) the folder content view will not be able
> to properly determine the title of the checked_out review state because
> checked_out is not a state of the simple_publishing_workflow.
> What I am struggling with is getting the current workflow policy for the
> object itself. When I call wf_tool.getChainFor(obj) it returns an empty
> list.

Hi Mike,

There is some code in the utils.py file from Products.plonehrm (it's
in the collective):

=========================================================
def set_plonehrm_workflow_policy(context):
    """Give the context the plonehrm placeful workflow policy."""
    pw = getToolByName(context, 'portal_placeful_workflow')
    config = pw.getWorkflowPolicyConfig(context)

    if not config:
        # Add the config.
        adder = context.manage_addProduct['CMFPlacefulWorkflow']
        adder.manage_addWorkflowPolicyConfig()
        config = pw.getWorkflowPolicyConfig(context)

    # Set the config.
    config.setPolicyIn(policy='plonehrm')
    getToolByName(context, 'portal_workflow').updateRoleMappings()
=========================================================

Not all of this is needed in your case, but it should get you on your way.

Cheers,

-- 
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]





More information about the Product-Developers mailing list