[Erp5-report] r44833 rafael - /erp5/trunk/products/ERP5Workflow/Document/Transition.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Mar 31 02:35:01 CEST 2011


Author: rafael
Date: Thu Mar 31 02:35:01 2011
New Revision: 44833

URL: http://svn.erp5.org?rev=44833&view=rev
Log:
Improve code style.

Modified:
    erp5/trunk/products/ERP5Workflow/Document/Transition.py

Modified: erp5/trunk/products/ERP5Workflow/Document/Transition.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Workflow/Document/Transition.py?rev=44833&r1=44832&r2=44833&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Workflow/Document/Transition.py [utf8] (original)
+++ erp5/trunk/products/ERP5Workflow/Document/Transition.py [utf8] Thu Mar 31 02:35:01 2011
@@ -30,8 +30,6 @@ from AccessControl import ClassSecurityI
 
 from Products.ERP5Type import Permissions, PropertySheet
 from Products.ERP5Type.XMLObject import XMLObject
-from zLOG import LOG, ERROR, DEBUG, WARNING
-from Products.PageTemplates.Expressions import getEngine
 from Products.ERP5Type.Accessor.Base import _evaluateTales
 
 class Transition(XMLObject):
@@ -62,6 +60,7 @@ class Transition(XMLObject):
     """
     Execute transition.
     """
+    workflow = self.getParentValue()
     # Call the before script
     self._executeBeforeScript(document)
 
@@ -69,41 +68,38 @@ class Transition(XMLObject):
     self._changeState(document)
 
     # Get variable values
-    status_dict = self.getParentValue().getCurrentStatusDict(document)
+    status_dict = workflow.getCurrentStatusDict(document)
     status_dict['undo'] = 0
 
     # Modify workflow history
-    state_bc_id = self.getParentValue().getStateBaseCategory()
+    state_bc_id = workflow.getStateBaseCategory()
     status_dict[state_bc_id] = document.getCategoryMembershipList(state_bc_id)[0]
 
     state_object = document.unrestrictedTraverse(status_dict[state_bc_id])
-    object = self.getParentValue().getStateChangeInformation(document, state_object, transition=self)
+    object = workflow.getStateChangeInformation(document, state_object, transition=self)
 
     # Update all variables
-    variable_list = self.getParentValue().contentValues(portal_type='Variable')
-    for variable in variable_list:
+    for variable in workflow.contentValues(portal_type='Variable'):
       if variable.getAutomaticUpdate():
-        # if we have it in form get it from there 
+        # if we have it in form get it from there
         # otherwise use default
         variable_title = variable.getTitle()
-        if form_kw.has_key(variable_title):
-           status_dict[variable_title] = form_kw[variable_title] 
+        if variable_title in form_kw:
+           status_dict[variable_title] = form_kw[variable_title]
         else:
           status_dict[variable_title] = variable.getInitialValue(object=object)
 
     # Update all transition variables
     if form_kw is not None:
       object.REQUEST.other.update(form_kw)
-    variable_list = self.contentValues(portal_type='Transition Variable')
-    for variable in variable_list:
+    for variable in self.contentValues(portal_type='Transition Variable'):
       status_dict[variable.getCausalityTitle()] = variable.getInitialValue(object=object)
-        
-    self.getParentValue()._updateWorkflowHistory(document, status_dict)
+
+    workflow._updateWorkflowHistory(document, status_dict)
 
     # Call the after script
     self._executeAfterScript(document, form_kw=form_kw)
 
-
   def _changeState(self, document):
     """
     Change the state of the object.
@@ -147,5 +143,5 @@ class Transition(XMLObject):
       value = _evaluateTales(document, expr_value)
     else:
       value = True
-    #print "CALC", expr_value, '-->', value 
+    #print "CALC", expr_value, '-->', value
     return value



More information about the Erp5-report mailing list