Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
CMFPlacefulWorkflow.DefaultWorkflowPolicy.DefaultWorkflowPolicyDefinition Class Reference
Inheritance diagram for CMFPlacefulWorkflow.DefaultWorkflowPolicy.DefaultWorkflowPolicyDefinition:
Inheritance graph
[legend]
Collaboration diagram for CMFPlacefulWorkflow.DefaultWorkflowPolicy.DefaultWorkflowPolicyDefinition:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getId
def getTitle
def getDescription
def setTitle
def setDescription
def manage_main
def manage_changeWorkflows
def setChainForPortalTypes
def getChainFor
def setDefaultChain
def getDefaultChain
def setChain
def delChain

Public Attributes

 id
 title
 description

Static Public Attributes

string meta_type = 'WorkflowPolicy'
string id = 'default_workflow_policy'
tuple security = ClassSecurityInfo()
tuple manage_options
tuple manage_changeWorkflows = postonly(manage_changeWorkflows)
tuple setChainForPortalTypes = postonly(setChainForPortalTypes)
tuple setDefaultChain = postonly(setDefaultChain)
tuple setChain = postonly(setChain)
tuple delChain = postonly(delChain)

Private Member Functions

def _listTypeInfo

Static Private Attributes

 __implements__ = IWorkflowPolicyDefinition
int _isAWorkflowPolicy = 1
 _chains_by_type = None
 _default_chain = None
tuple _manage_workflows

Detailed Description

Definition at line 49 of file DefaultWorkflowPolicy.py.


Constructor & Destructor Documentation

Definition at line 75 of file DefaultWorkflowPolicy.py.

00075 
00076     def __init__(self, id):
00077         self.id = id
00078         self.title = ''
00079         self.description = ''


Member Function Documentation

List the portal types which are available.

Definition at line 299 of file DefaultWorkflowPolicy.py.

00299 
00300     def _listTypeInfo(self):
00301 
00302         """ List the portal types which are available.
00303         """
00304         pt = getToolByName(self, 'portal_types', None)
00305         if pt is None:
00306             return ()
00307         else:
00308             return pt.listTypeInfo()
00309 
00310 
00311 InitializeClass(DefaultWorkflowPolicyDefinition)
00312 
00313 addWorkflowPolicyFactory(DefaultWorkflowPolicyDefinition, title='Simple Policy')
00314 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlacefulWorkflow.DefaultWorkflowPolicy.DefaultWorkflowPolicyDefinition.delChain (   self,
  portal_type,
  REQUEST = None 
)
Delete the chain for a portal type.

Definition at line 289 of file DefaultWorkflowPolicy.py.

00289 
00290     def delChain(self, portal_type, REQUEST=None):
00291         """Delete the chain for a portal type."""
00292         if self._chains_by_type.has_key(portal_type):
            del self._chains_by_type[portal_type]
Returns the chain that applies to the object.

If chain doesn't exist we return None to get a fallback from portal_workflow.
We never return emtpy tuple that is good value for a chain.

Definition at line 191 of file DefaultWorkflowPolicy.py.

00191 
00192     def getChainFor(self, ob, managescreen=False):
00193         """Returns the chain that applies to the object.
00194 
00195         If chain doesn't exist we return None to get a fallback from portal_workflow.
00196         We never return emtpy tuple that is good value for a chain.
00197         """
00198 
00199         cbt = self._chains_by_type
00200         if type(ob) == type(''):
00201             pt = ob
00202         elif hasattr(aq_base(ob), '_getPortalTypeName'):
00203             pt = ob._getPortalTypeName()
00204         else:
00205             pt = None
00206 
00207         if pt is None:
00208             return None
00209 
00210         chain = None
00211         if cbt is not None:
00212             chain = cbt.get(pt, _MARKER)
00213 
00214         # Backwards compatibility: before chain was a string, not a list
00215         if chain is not _MARKER and type(chain) == type(''):
00216             chain = map( lambda x: x.strip(), chain.split(',') )
00217 
00218         Log(LOG_DEBUG, 'Chain founded in policy', chain)
00219         if chain is _MARKER or chain is None:
00220             return None
00221         elif len(chain) == 1 and chain[0] == DEFAULT_CHAIN:
00222             default = self.getDefaultChain(ob)
00223             if default:
00224                 if managescreen:
00225                     return chain[0]
00226                 else:
00227                     return default
00228             else:
00229                 return None
00230 
00231         return chain

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the default chain.

Definition at line 252 of file DefaultWorkflowPolicy.py.

00252 
00253     def getDefaultChain(self, ob):
00254         """ Returns the default chain."""
00255         if self._default_chain is None:
00256             wf_tool = getToolByName(self, 'portal_workflow')
00257             return wf_tool.getDefaultChainFor(ob)
00258         else:
00259             return self._default_chain

Here is the call graph for this function:

Here is the caller graph for this function:

Return the description

Definition at line 94 of file DefaultWorkflowPolicy.py.

00094 
00095     def getDescription(self):
00096         """ Return the description
00097         """
00098         description = getattr(self, 'description', '')
00099         return description

Here is the caller graph for this function:

Return the id

Definition at line 81 of file DefaultWorkflowPolicy.py.

00081 
00082     def getId(self):
00083         """ Return the id
00084         """
00085         return self.id

Return the title

Definition at line 87 of file DefaultWorkflowPolicy.py.

00087 
00088     def getTitle(self):
00089         """ Return the title
00090         """
00091         title = getattr(self, 'title', '')
00092         return title

def CMFPlacefulWorkflow.DefaultWorkflowPolicy.DefaultWorkflowPolicyDefinition.manage_changeWorkflows (   self,
  title,
  description,
  default_chain,
  props = None,
  REQUEST = None 
)
Changes which workflows apply to objects of which type

A chain equal to 'None' is empty we remove the entry.

Definition at line 147 of file DefaultWorkflowPolicy.py.

00147 
00148     def manage_changeWorkflows(self, title, description, default_chain, props=None, REQUEST=None):
00149         """ Changes which workflows apply to objects of which type
00150 
00151         A chain equal to 'None' is empty we remove the entry.
00152         """
00153         self.title = title
00154         self.description = description
00155 
00156         wf_tool = getToolByName(self, 'portal_workflow')
00157 
00158         if props is None:
00159             props = REQUEST
00160         cbt = self._chains_by_type
00161         if cbt is None:
00162             self._chains_by_type = cbt = PersistentMapping()
00163         ti = self._listTypeInfo()
00164         # Set up the chains by type.
00165         for t in ti:
00166             id = t.getId()
00167             field_name = 'chain_%s' % id
00168             chain = props.get(field_name, DEFAULT_CHAIN).strip()
00169 
00170             if chain == 'None':
00171                 if cbt.get(id, _MARKER) is not _MARKER:
00172                     self.delChain(id)
00173                 continue
00174 
00175             self.setChain(id, chain)
00176 
00177         # Set up the default chain.
00178         self.setDefaultChain(default_chain)
00179         if REQUEST is not None:
            return self.manage_main(REQUEST, manage_tabs_message='Changed.')

Here is the call graph for this function:

def CMFPlacefulWorkflow.DefaultWorkflowPolicy.DefaultWorkflowPolicyDefinition.manage_main (   self,
  REQUEST,
  manage_tabs_message = None 
)
Show a management screen for changing type to workflow connections

Display 'None' if there's no chain for a type.

Definition at line 113 of file DefaultWorkflowPolicy.py.

00113 
00114     def manage_main(self, REQUEST, manage_tabs_message=None):
00115         """ Show a management screen for changing type to workflow connections
00116 
00117         Display 'None' if there's no chain for a type.
00118         """
00119         cbt = self._chains_by_type
00120         ti = self._listTypeInfo()
00121         types_info = []
00122         for t in ti:
00123             id = t.getId()
00124             title = t.Title()
00125             if title == id:
00126                 title = None
00127 
00128             if cbt is not None and cbt.has_key(id):
00129                 chain = ', '.join(cbt[id])
00130             else:
00131                 chain = 'None'
00132 
00133             types_info.append({
00134                 'id': id,
00135                 'title': title,
00136                 'chain': chain,
00137                 #'cbt': repr(cbt.get(id)), # for debug purpose
00138             })
00139         return self._manage_workflows(
00140             REQUEST,
00141             default_chain=', '.join(self._default_chain or ()),
00142             types_info=types_info,
00143             management_view='Workflows',
00144             manage_tabs_message=manage_tabs_message)
00145 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlacefulWorkflow.DefaultWorkflowPolicy.DefaultWorkflowPolicyDefinition.setChain (   self,
  portal_type,
  chain,
  REQUEST = None 
)
Set the chain for a portal type.

Definition at line 261 of file DefaultWorkflowPolicy.py.

00261 
00262     def setChain(self, portal_type, chain, REQUEST=None):
00263         """Set the chain for a portal type."""
00264         # Verify input data
00265         if portal_type not in [pt.id for pt in self._listTypeInfo()]:
00266             raise ValueError, ("'%s' is not a valid portal type." % portal_type)
00267 
00268         if type(chain) is type(''):
00269             chain = map( lambda x: x.strip(), chain.split(',') )
00270 
00271         wftool = getToolByName(self, 'portal_workflow')
00272         cbt = self._chains_by_type
00273         if cbt is None:
00274             self._chains_by_type = cbt = PersistentMapping()
00275 
00276         # if chain is None or default, we remove the entry
00277         if chain is None and cbt.has_key(portal_type):
00278             del cbt[portal_type]
00279         elif len(chain) == 1 and chain[0] == DEFAULT_CHAIN:
00280             cbt[portal_type] = chain
00281         else:
00282             for wf_id in chain:
00283                 if wf_id != '' and not wftool.getWorkflowById(wf_id):
00284                     raise ValueError, ("'%s' is not a workflow ID.\nchain: %s" % (
00285                         wf_id, repr(chain)))
            cbt[portal_type] = tuple(chain)

Here is the call graph for this function:

Set a chain for portal types.

Definition at line 183 of file DefaultWorkflowPolicy.py.

00183 
00184     def setChainForPortalTypes(self, pt_names, chain, REQUEST=None):
00185         """ Set a chain for portal types.
00186         """
00187         for portal_type in pt_names:
            self.setChain(portal_type, chain)
Sets the default chain for this tool. 

Definition at line 233 of file DefaultWorkflowPolicy.py.

00233 
00234     def setDefaultChain(self, default_chain, REQUEST=None):
00235 
00236         """ Sets the default chain for this tool. """
00237         wftool = getToolByName(self, 'portal_workflow')
00238 
00239         if type(default_chain) is type(''):
00240             default_chain = map( lambda x: x.strip(), default_chain.split(',') )
00241         ids = []
00242         for wf_id in default_chain:
00243             if wf_id:
00244                 if not wftool.getWorkflowById(wf_id):
00245                     raise ValueError, ("'%s' is not a workflow ID.\nchain: %s" % (
00246                         wf_id, repr(chain)))
00247                 ids.append(wf_id)
00248 
        self._default_chain = tuple(ids)

Here is the call graph for this function:

Set the description

Definition at line 107 of file DefaultWorkflowPolicy.py.

00107 
00108     def setDescription(self, description):
00109         """ Set the description
00110         """
00111         self.description = description

Here is the caller graph for this function:

Set the title

Definition at line 101 of file DefaultWorkflowPolicy.py.

00101 
00102     def setTitle(self, title):
00103         """ Set the title
00104         """
00105         self.title=title

Here is the caller graph for this function:


Member Data Documentation

Definition at line 51 of file DefaultWorkflowPolicy.py.

Definition at line 57 of file DefaultWorkflowPolicy.py.

Definition at line 58 of file DefaultWorkflowPolicy.py.

Definition at line 55 of file DefaultWorkflowPolicy.py.

Initial value:
PageTemplateFile(path_join('www', 'define_local_workflow_policy'),
                                              globals(),
                                              __name__= 'manage_main')

Definition at line 71 of file DefaultWorkflowPolicy.py.

Definition at line 293 of file DefaultWorkflowPolicy.py.

Definition at line 78 of file DefaultWorkflowPolicy.py.

Definition at line 54 of file DefaultWorkflowPolicy.py.

Definition at line 76 of file DefaultWorkflowPolicy.py.

Definition at line 180 of file DefaultWorkflowPolicy.py.

Initial value:
(
        { 'label' : 'Workflows', 'action' : 'manage_main'},
    )

Definition at line 62 of file DefaultWorkflowPolicy.py.

Definition at line 53 of file DefaultWorkflowPolicy.py.

Definition at line 60 of file DefaultWorkflowPolicy.py.

Definition at line 286 of file DefaultWorkflowPolicy.py.

Definition at line 188 of file DefaultWorkflowPolicy.py.

Definition at line 249 of file DefaultWorkflowPolicy.py.

Definition at line 77 of file DefaultWorkflowPolicy.py.


The documentation for this class was generated from the following file: