[Checkins] SVN: Products.DCWorkflow/branches/2.2/Products/DCWorkflow/ Fix an issue with Generic Setup and non-ascii chars in workflow definition
Erico Andrei
erico at simplesconsultoria.com.br
Tue May 3 09:13:36 EDT 2011
Log message for revision 121521:
Fix an issue with Generic Setup and non-ascii chars in workflow definition
Changed:
U Products.DCWorkflow/branches/2.2/Products/DCWorkflow/CHANGES.txt
U Products.DCWorkflow/branches/2.2/Products/DCWorkflow/exportimport.py
U Products.DCWorkflow/branches/2.2/Products/DCWorkflow/tests/test_exportimport.py
-=-
Modified: Products.DCWorkflow/branches/2.2/Products/DCWorkflow/CHANGES.txt
===================================================================
--- Products.DCWorkflow/branches/2.2/Products/DCWorkflow/CHANGES.txt 2011-05-03 10:56:18 UTC (rev 121520)
+++ Products.DCWorkflow/branches/2.2/Products/DCWorkflow/CHANGES.txt 2011-05-03 13:13:36 UTC (rev 121521)
@@ -4,6 +4,8 @@
2.2.4 (unreleased)
------------------
+- Fixed issue with non-ascii chars in workflow definitions
+
- Don't crash worklist's ``manage_main`` if variables are Expression objects.
(https://bugs.launchpad.net/zope-cmf/+bug/731394)
Modified: Products.DCWorkflow/branches/2.2/Products/DCWorkflow/exportimport.py
===================================================================
--- Products.DCWorkflow/branches/2.2/Products/DCWorkflow/exportimport.py 2011-05-03 10:56:18 UTC (rev 121520)
+++ Products.DCWorkflow/branches/2.2/Products/DCWorkflow/exportimport.py 2011-05-03 13:13:36 UTC (rev 121521)
@@ -49,7 +49,9 @@
"""Export the object as a file body.
"""
wfdc = WorkflowDefinitionConfigurator(self.context)
- return wfdc.__of__(self.context).generateWorkflowXML()
+ body = wfdc.__of__(self.context).generateWorkflowXML()
+ body = body.encode('utf-8')
+ return body
def _importBody(self, body):
"""Import the object from the file body.
Modified: Products.DCWorkflow/branches/2.2/Products/DCWorkflow/tests/test_exportimport.py
===================================================================
--- Products.DCWorkflow/branches/2.2/Products/DCWorkflow/tests/test_exportimport.py 2011-05-03 10:56:18 UTC (rev 121520)
+++ Products.DCWorkflow/branches/2.2/Products/DCWorkflow/tests/test_exportimport.py 2011-05-03 13:13:36 UTC (rev 121521)
@@ -1,4 +1,5 @@
-##############################################################################
+# -*- coding:utf-8 -*-
+###############################################################################
#
# Copyright (c) 2004 Zope Foundation and Contributors.
#
@@ -16,6 +17,8 @@
import unittest
import Testing
+from StringIO import StringIO
+
from Products.PythonScripts.PythonScript import PythonScript
from Products.ExternalMethod.ExternalMethod import ExternalMethod
@@ -33,6 +36,7 @@
from Products.DCWorkflow.Transitions import TRIGGER_AUTOMATIC
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
+from Products.GenericSetup.tests.common import TarballTester
class _GuardChecker:
@@ -1978,7 +1982,48 @@
self.assertEqual( text, _AFTER_CLOSE_SCRIPT)
self.assertEqual( content_type, 'text/plain' )
+class Test_exportUTFWorkflow(Test_exportWorkflow,TarballTester):
+ layer = ExportImportZCMLLayer
+
+ def test_utf_strings( self ):
+ from Products.CMFCore.exportimport.workflow import exportWorkflowTool
+ from Products.GenericSetup.context import TarballExportContext
+
+ WF_ID_DC = 'workflow'
+ WF_TITLE_DC = u'A workflow with special chars like è é'
+ WF_DESCRIPTION_DC = u'A workflow with lots of special chars ç'
+ WF_INITIAL_STATE = 'closed'
+
+ site = self._initSite()
+
+ dcworkflow = self._initDCWorkflow( WF_ID_DC )
+ dcworkflow.title = WF_TITLE_DC
+ dcworkflow.description = WF_DESCRIPTION_DC
+ dcworkflow.initial_state = WF_INITIAL_STATE
+ dcworkflow.permissions = _WF_PERMISSIONS
+ self._initVariables( dcworkflow )
+ self._initStates( dcworkflow )
+ self._initTransitions( dcworkflow )
+ self._initWorklists( dcworkflow )
+ ctx = TarballExportContext(site)
+
+ context = DummyExportContext( site )
+ exportWorkflowTool( context )
+ self.assertEqual( len( context._wrote ), 2 )
+ for filename, text, content_type in context._wrote:
+ ctx.writeDataFile( filename, text, content_type)
+ fileish = StringIO( ctx.getArchive() )
+ self._verifyTarballContents( fileish,
+ ['workflows/workflow', 'workflows',
+ 'workflows.xml',
+ 'workflows/workflow/definition.xml'])
+ self._verifyTarballEntry( fileish, 'workflows.xml',
+ context._wrote[0][1] )
+ self._verifyTarballEntry( fileish, 'workflows/workflow/definition.xml',
+ context._wrote[1][1] )
+
+
class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
layer = ExportImportZCMLLayer
@@ -2552,5 +2597,6 @@
return unittest.TestSuite((
unittest.makeSuite( WorkflowDefinitionConfiguratorTests ),
unittest.makeSuite( Test_exportWorkflow ),
+ unittest.makeSuite( Test_exportUTFWorkflow),
unittest.makeSuite( Test_importWorkflow ),
))
More information about the checkins
mailing list