[Zope3-checkins] CVS: Packages3/workflow/stateful - instance.py:1.10
Ulrich Eck
ueck@net-labs.de
Wed, 26 Mar 2003 16:10:59 -0500
Update of /cvs-repository/Packages3/workflow/stateful
In directory cvs.zope.org:/tmp/cvs-serv10185/stateful
Modified Files:
instance.py
Log Message:
little optimization for instance.py
=== Packages3/workflow/stateful/instance.py 1.9 => 1.10 ===
--- Packages3/workflow/stateful/instance.py:1.9 Wed Mar 26 14:24:05 2003
+++ Packages3/workflow/stateful/instance.py Wed Mar 26 16:10:59 2003
@@ -93,51 +93,26 @@
# setup permission on data
# check for Automatic Transitions
- self._checkAndFireAuto()
+ self._checkAndFireAuto(clean_pd)
initialize = ContextMethod(initialize)
def getOutgoingTransitions(self):
- ret = []
pd = self._getProcessDefinition()
clean_pd = removeAllProxies(pd)
- sm = getSecurityManager()
-
- for name, trans in clean_pd.transitions.items():
- if self.status == trans.sourceState:
- # check permissions
- permission = trans.permission
- if (permission is not None
- and permission != 'zope.Public'
- and not sm.checkPermission(permission, self)
- ):
- continue
-
-
- # evaluate conditions
- if trans.condition is not None:
- try:
- include = self._evaluateCondition(trans)
- except Unauthorized:
- include = 0
- if not include:
- continue
-
- # append transition name
- ret.append(name)
- return ret
+ return self._outgoingTransitions(clean_pd)
getOutgoingTransitions = ContextMethod(getOutgoingTransitions)
def fireTransition(self, id):
pd = self._getProcessDefinition()
clean_pd = removeAllProxies(pd)
- if not id in self.getOutgoingTransitions():
+ if not id in self._outgoingTransitions(clean_pd):
raise KeyError, 'Invalid Transition Id: %s' % id
trans = clean_pd.transitions[id]
# modify relevant-data if needed
self._status = trans.destinationState
# check for automatic transitions
- self._checkAndFireAuto()
+ self._checkAndFireAuto(clean_pd)
fireTransition = ContextMethod(fireTransition)
#
@@ -181,14 +156,40 @@
setattr(data, name, field.default)
return data
- def _checkAndFireAuto(self):
- pd = self._getProcessDefinition()
- clean_pd = removeAllProxies(pd)
+
+ def _outgoingTransitions(self, clean_pd):
+ sm = getSecurityManager()
+ ret = []
+ for name, trans in clean_pd.transitions.items():
+ if self.status == trans.sourceState:
+ # check permissions
+ permission = trans.permission
+ if (permission is not None
+ and permission != 'zope.Public'
+ and not sm.checkPermission(permission, self)
+ ):
+ continue
+
+ # evaluate conditions
+ if trans.condition is not None:
+ try:
+ include = self._evaluateCondition(trans)
+ except Unauthorized:
+ include = 0
+ if not include:
+ continue
+
+ # append transition name
+ ret.append(name)
+ return ret
+
+
+ def _checkAndFireAuto(self, clean_pd):
outgoing_transitions = self.getOutgoingTransitions()
for name in outgoing_transitions:
trans = clean_pd.transitions[name]
if trans.triggerMode == 'Automatic':
self.fireTransition(name)
return
-
_checkAndFireAuto = ContextMethod(_checkAndFireAuto)
+