From cf1d0aa8df329f45bd20044b5b86c3fb057a7533 Mon Sep 17 00:00:00 2001
From: Kevin Deldycke <kevin@nexedi.com>
Date: Wed, 5 Oct 2005 20:10:49 +0000
Subject: [PATCH] Generate methods that support the translation of workflow
 states

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3966 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Base.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py
index 1ecead0aa1..f1ef314bf9 100755
--- a/product/ERP5Type/Base.py
+++ b/product/ERP5Type/Base.py
@@ -204,6 +204,22 @@ def initializePortalTypeDynamicProperties(self, klass, ptype):
           prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
           #LOG('in aq_portal_type %s' % id, 0, "added state method %s" % method_id)
       #LOG('in aq_portal_type %s' % id, 0, "found transition workflow %s" % wf.id)
+    # Generate methods that support the translation of workflow states
+    for wf in portal_workflow.getWorkflowsFor(self):
+      wf_id = wf.id
+      if wf.__class__.__name__ in ('DCWorkflowDefinition', ):
+        # Create state var accessor
+        state_var = wf.variables.getStateVar()
+        method_id = 'getTranslated%s' % UpperCase(state_var)
+        if not hasattr(prop_holder, method_id):
+          method = WorkflowState.TranslatedGetter(method_id, wf_id)
+          setattr(prop_holder, method_id, method) # Attach to portal_type
+          prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
+        method_id = 'getTranslated%sTitle' % UpperCase(state_var)
+        if not hasattr(prop_holder, method_id):
+          method = WorkflowState.TranslatedTitleGetter(method_id, wf_id)
+          setattr(prop_holder, method_id, method) # Attach to portal_type
+          prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
       if wf.__class__.__name__ in ('DCWorkflowDefinition', ):
         for tr_id in wf.transitions.objectIds():
           tdef = wf.transitions.get(tr_id, None)
-- 
2.30.9