appy.gen: bugfixes in the new workflow engine and in macro 'history'.
This commit is contained in:
parent
1cd9aaaf69
commit
5be03c2ed4
|
@ -2384,6 +2384,7 @@ class Transition:
|
||||||
|
|
||||||
def isTriggerable(self, obj, wf):
|
def isTriggerable(self, obj, wf):
|
||||||
'''Can this transition be triggered on p_obj?'''
|
'''Can this transition be triggered on p_obj?'''
|
||||||
|
wf = wf.__instance__ # We need the prototypical instance here.
|
||||||
# Checks that the current state of the object is a start state for this
|
# Checks that the current state of the object is a start state for this
|
||||||
# transition.
|
# transition.
|
||||||
objState = obj.getState(name=False)
|
objState = obj.getState(name=False)
|
||||||
|
@ -2424,13 +2425,15 @@ class Transition:
|
||||||
def executeAction(self, obj, wf):
|
def executeAction(self, obj, wf):
|
||||||
'''Executes the action related to this transition.'''
|
'''Executes the action related to this transition.'''
|
||||||
msg = ''
|
msg = ''
|
||||||
|
obj = obj.appy()
|
||||||
|
wf = wf.__instance__ # We need the prototypical instance here.
|
||||||
if type(self.action) in (tuple, list):
|
if type(self.action) in (tuple, list):
|
||||||
# We need to execute a list of actions
|
# We need to execute a list of actions
|
||||||
for act in self.action:
|
for act in self.action:
|
||||||
msgPart = act(wf, obj.appy())
|
msgPart = act(wf, obj)
|
||||||
if msgPart: msg += msgPart
|
if msgPart: msg += msgPart
|
||||||
else: # We execute a single action only.
|
else: # We execute a single action only.
|
||||||
msgPart = self.action(wf, obj.appy())
|
msgPart = self.action(wf, obj)
|
||||||
if msgPart: msg += msgPart
|
if msgPart: msg += msgPart
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
@ -2555,12 +2558,14 @@ class WorkflowAnonymous:
|
||||||
'''One-state workflow allowing anyone to consult and Manager to edit.'''
|
'''One-state workflow allowing anyone to consult and Manager to edit.'''
|
||||||
mgr = 'Manager'
|
mgr = 'Manager'
|
||||||
active = State({r:(mgr, 'Anonymous'), w:mgr, d:mgr}, initial=True)
|
active = State({r:(mgr, 'Anonymous'), w:mgr, d:mgr}, initial=True)
|
||||||
|
WorkflowAnonymous.__instance__ = WorkflowAnonymous()
|
||||||
|
|
||||||
class WorkflowAuthenticated:
|
class WorkflowAuthenticated:
|
||||||
'''One-state workflow allowing authenticated users to consult and Manager
|
'''One-state workflow allowing authenticated users to consult and Manager
|
||||||
to edit.'''
|
to edit.'''
|
||||||
mgr = 'Manager'
|
mgr = 'Manager'
|
||||||
active = State({r:(mgr, 'Authenticated'), w:mgr, d:mgr}, initial=True)
|
active = State({r:(mgr, 'Authenticated'), w:mgr, d:mgr}, initial=True)
|
||||||
|
WorkflowAuthenticated.__instance__ = WorkflowAuthenticated()
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
class Selection:
|
class Selection:
|
||||||
|
|
|
@ -588,7 +588,6 @@ class ZopeInstaller:
|
||||||
permission = self.defaultAddContentPermission,
|
permission = self.defaultAddContentPermission,
|
||||||
extra_constructors = constructors, fti = ftis).initialize(
|
extra_constructors = constructors, fti = ftis).initialize(
|
||||||
self.zopeContext)
|
self.zopeContext)
|
||||||
|
|
||||||
# Define content-specific "add" permissions
|
# Define content-specific "add" permissions
|
||||||
for i in range(0, len(contentTypes)):
|
for i in range(0, len(contentTypes)):
|
||||||
className = contentTypes[i].__name__
|
className = contentTypes[i].__name__
|
||||||
|
@ -596,6 +595,11 @@ class ZopeInstaller:
|
||||||
self.zopeContext.registerClass(meta_type = ftis[i]['meta_type'],
|
self.zopeContext.registerClass(meta_type = ftis[i]['meta_type'],
|
||||||
constructors = (constructors[i],),
|
constructors = (constructors[i],),
|
||||||
permission = self.addContentPermissions[className])
|
permission = self.addContentPermissions[className])
|
||||||
|
# Create workflow prototypical instances in __instance__ attributes
|
||||||
|
for contentType in contentTypes:
|
||||||
|
wf = getattr(contentType.wrapperClass, 'workflow', None)
|
||||||
|
if wf and not hasattr(wf, '__instance__'):
|
||||||
|
wf.__instance__ = wf()
|
||||||
|
|
||||||
def enableUserTracking(self):
|
def enableUserTracking(self):
|
||||||
'''Enables the machinery allowing to know who is currently logged in.
|
'''Enables the machinery allowing to know who is currently logged in.
|
||||||
|
|
|
@ -951,7 +951,7 @@ class BaseMixin:
|
||||||
# Is this transition triggerable?
|
# Is this transition triggerable?
|
||||||
transition = getattr(wf, transitionName)
|
transition = getattr(wf, transitionName)
|
||||||
if not transition.isTriggerable(self, wf):
|
if not transition.isTriggerable(self, wf):
|
||||||
raise 'Transition "%s" can\'t be triggered' % transitionName
|
raise 'Transition "%s" can\'t be triggered.' % transitionName
|
||||||
# Trigger the transition
|
# Trigger the transition
|
||||||
transition.trigger(transitionName, self, wf, comment, doAction=doAction,
|
transition.trigger(transitionName, self, wf, comment, doAction=doAction,
|
||||||
doNotify=doNotify, doHistory=doHistory, doSay=doSay)
|
doNotify=doNotify, doHistory=doHistory, doSay=doSay)
|
||||||
|
|
|
@ -468,15 +468,16 @@
|
||||||
<th align="left" width="70%" tal:content="python: tool.translate('previous_value')"></th>
|
<th align="left" width="70%" tal:content="python: tool.translate('previous_value')"></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr tal:repeat="change event/changes/items" valign="top">
|
<tr tal:repeat="change event/changes/items" valign="top">
|
||||||
<td tal:content="structure python: tool.translate(change[1][1])"></td>
|
<tal:change define="appyType python:contextObj.getAppyType(change[0], asDict=True);">
|
||||||
|
<td tal:content="structure python: tool.translate(appyType['labelId'])"></td>
|
||||||
<td tal:define="appyValue python: contextObj.getFormattedFieldValue(change[0], change[1][0]);
|
<td tal:define="appyValue python: contextObj.getFormattedFieldValue(change[0], change[1][0]);
|
||||||
appyType python:contextObj.getAppyType(change[0], asDict=True);
|
|
||||||
severalValues python: (appyType['multiplicity'][1] > 1) or (appyType['multiplicity'][1] == None)">
|
severalValues python: (appyType['multiplicity'][1] > 1) or (appyType['multiplicity'][1] == None)">
|
||||||
<span tal:condition="not: severalValues" tal:replace="appyValue"></span>
|
<span tal:condition="not: severalValues" tal:replace="appyValue"></span>
|
||||||
<ul tal:condition="python: severalValues">
|
<ul tal:condition="python: severalValues">
|
||||||
<li tal:repeat="av appyValue" tal:content="av"></li>
|
<li tal:repeat="av appyValue" tal:content="av"></li>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
|
</tal:change>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in a new issue