Back to index

plone3  3.1.7
Functions | Variables
CMFPlacefulWorkflow.adapter Namespace Reference

Functions

def PlacefulWorkflowChain

Variables

string __version__ = "$Revision: $"
 -*- coding: utf-8 -*- Copyright (C) 2008 Ingeniweb
string __docformat__ = 'restructuredtext'

Function Documentation

Monkey-patched by CMFPlacefulWorkflow to look for placeful workflow configurations.

Goal: find a workflow chain in a policy

Steps:
1. ask the object if it contains a policy
2. if it does, ask him for a chain
3. if there's no chain for the type the we loop on the parent
4. if the parent is the portal object or None we stop and ask
   portal_workflow

Definition at line 36 of file adapter.py.

00036 
00037 def PlacefulWorkflowChain(ob, tool):
00038     """Monkey-patched by CMFPlacefulWorkflow to look for placeful workflow configurations.
00039 
00040     Goal: find a workflow chain in a policy
00041 
00042     Steps:
00043     1. ask the object if it contains a policy
00044     2. if it does, ask him for a chain
00045     3. if there's no chain for the type the we loop on the parent
00046     4. if the parent is the portal object or None we stop and ask
00047        portal_workflow
00048     """
00049     if isinstance(ob, basestring):
00050         # We are not in an object, then we can only get default from
00051         # portal_workflow
00052         return ToolWorkflowChain(ob, tool)
00053 
00054     elif hasattr(aq_base(ob), 'getPortalTypeName'):
00055         portal_type = ob.getPortalTypeName()
00056     else:
00057         portal_type = None
00058 
00059     if portal_type is None or ob is None:
00060         return ()
00061 
00062     # Inspired by implementation in CPSWorkflowTool.py of CPSCore 3.9.0
00063     # Workflow needs to be determined by true containment not context
00064     # so we loop over the actual containers
00065     chain = None
00066     wfpolicyconfig = None
00067     current_ob = aq_inner(ob)
00068     # start_here is used to check 'In policy': We check it only in the
00069     # first folder
00070     start_here = True
00071     portal = aq_base(getToolByName(tool, 'portal_url').getPortalObject())
00072     while chain is None and current_ob is not None:
00073         if base_hasattr(current_ob, WorkflowPolicyConfig_id):
00074             wfpolicyconfig = getattr(current_ob, WorkflowPolicyConfig_id)
00075             chain = wfpolicyconfig.getPlacefulChainFor(portal_type,
00076                                                        start_here=start_here)
00077             if chain is not None:
00078                 return chain
00079 
00080         elif aq_base(current_ob) is portal:
00081             break
00082         start_here = False
00083         current_ob = aq_inner(aq_parent(current_ob))
00084 
00085     # fallback on the default mechanism
00086     return ToolWorkflowChain(ob, tool)

Here is the call graph for this function:


Variable Documentation

string CMFPlacefulWorkflow.adapter.__docformat__ = 'restructuredtext'

Definition at line 21 of file adapter.py.

string CMFPlacefulWorkflow.adapter.__version__ = "$Revision: $"

-*- coding: utf-8 -*- Copyright (C) 2008 Ingeniweb

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Definition at line 18 of file adapter.py.