Back to index

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

List of all members.

Public Member Functions

def name

Private Member Functions

def _extractChains
def _initChains
def _getChain

Static Private Attributes

string _LOGGER_ID = 'placeful_workflow'

Detailed Description

Definition at line 44 of file workflow_policies.py.


Member Function Documentation

Definition at line 53 of file workflow_policies.py.

00053 
00054     def _extractChains(self):
00055         fragment = self._doc.createDocumentFragment()
00056         node = self._doc.createElement('bindings')
00057         child = self._doc.createElement('default')
00058         for workflow_id in self.context._default_chain or ():
00059             sub = self._doc.createElement('bound-workflow')
00060             sub.setAttribute('workflow_id', workflow_id)
00061             child.appendChild(sub)
00062         node.appendChild(child)
00063         if self.context._chains_by_type:
00064             typestool = getToolByName(self.context, 'portal_types')
00065             typeinfos = sorted(typestool.listTypeInfo(),
00066                                key=lambda type: type.getId())
00067             for ti in typeinfos:
00068                 type_id = ti.getId()
00069                 chain = self.context._chains_by_type.get(type_id, _marker)
00070                 child = self._doc.createElement('type')
00071                 if chain is _marker:
00072                     # If no chain is defined chain is acquired
00073                     continue
00074 
00075                 if chain == (DEFAULT_CHAIN,):
00076                     # If the type is using the default chain there's no chain
00077                     # to wait after the attribute
00078                     child.setAttribute('type_id', type_id)
00079                     child.setAttribute('default_chain', "true")
00080                     node.appendChild(child)
00081                     continue
00082 
00083                 child.setAttribute('type_id', type_id)
00084                 for workflow_id in chain:
00085                     sub = self._doc.createElement('bound-workflow')
00086                     sub.setAttribute('workflow_id', workflow_id)
00087                     child.appendChild(sub)
00088                 node.appendChild(child)
00089         fragment.appendChild(node)
00090         return fragment

Here is the call graph for this function:

Definition at line 130 of file workflow_policies.py.

00130 
00131     def _getChain(self, node):
00132         result = super(WorkflowPoliciesXMLAdapter,
00133                        self)._getChain(node)
00134         if result == '':
00135             return []
00136         return result.split(',')

Here is the caller graph for this function:

Import policies from XML

Types specified are in two cases:

- a default_chain attribute is present

- zero or more workflows are presents then type take the chain in the
  same order

For any types not specified, we do nothing and they will acquire their
chain from another policy or from portal_workfow.

Definition at line 91 of file workflow_policies.py.

00091 
00092     def _initChains(self, node):
00093         """ Import policies from XML
00094 
00095         Types specified are in two cases:
00096 
00097         - a default_chain attribute is present
00098 
00099         - zero or more workflows are presents then type take the chain in the
00100           same order
00101 
00102         For any types not specified, we do nothing and they will acquire their
00103         chain from another policy or from portal_workfow.
00104         """
00105         seen = set()
00106         for child in node.childNodes:
00107             if child.nodeName != 'bindings':
00108                 continue
00109             for sub in child.childNodes:
00110                 if sub.nodeName == 'default':
00111                     self.context.setDefaultChain(self._getChain(sub))
00112                 if sub.nodeName == 'type':
00113                     type_id = str(sub.getAttribute('type_id'))
00114                     assert type_id not in seen, (
00115                         'Type %s listed more than once' % type_id)
00116                     seen.add(type_id)
00117 
00118                     default = sub.getAttribute('default_chain')
00119                     chain = self._getChain(sub)
00120                     Log(LOG_DEBUG, default, chain)
00121                     assert not (default and chain), (
00122                         'Type %s is marked to use default but also '
00123                         'included a chain: %s' % (type_id, chain))
00124                     if default:
00125                         # omit from the policy to acquire
00126                         self.context.setChain(type_id, (DEFAULT_CHAIN,))
00127                     else:
00128                         self.context.setChain(type_id, chain)
00129 

Here is the call graph for this function:

Definition at line 49 of file workflow_policies.py.

00049 
00050     def name(self):
00051         Log(LOG_DEBUG, self.context.id)
00052         return self.context.id

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 46 of file workflow_policies.py.


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