allow for more than one 'doBefore' function in a transition

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@4202 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2011-03-15 08:53:59 +00:00
parent c7060245e1
commit bf8a85453c

View file

@ -53,6 +53,7 @@ class Action(object):
allowed = True
permission = None
roles = []
doBefore = []
def __init__(self, name, title=None, **kw):
self.name = self.__name__ = name
@ -60,10 +61,6 @@ class Action(object):
for k, v in kw.items():
setattr(self, k, v)
@staticmethod
def doBefore(context):
return None
class Transition(Action):
@ -106,7 +103,11 @@ class StatesDefinition(object):
if trans not in self.getAvailableTransitionsFor(obj):
raise ValueError("Transition '%s' is not reachable from state '%s'."
% (transition, obj.getState()))
trans.doBefore(obj)
if isinstance(trans.doBefore, (list, tuple)):
for fct in trans.doBefore:
fct(obj)
else:
trans.doBefore(obj)
obj.state = trans.targetState
obj.getStateObject().setSecurity(obj)