diff --git a/product/ERP5Type/ZopePatch.py b/product/ERP5Type/ZopePatch.py index 4b26663338f625468b20802233ad35fcd87d8c7c..b5064e1a801f3460e71e4c4d0f3085482c2ce05a 100644 --- a/product/ERP5Type/ZopePatch.py +++ b/product/ERP5Type/ZopePatch.py @@ -54,7 +54,6 @@ from Products.ERP5Type.patches import PersistencePatch from Products.ERP5Type.patches import PersistentMapping from Products.ERP5Type.patches import DateTimePatch from Products.ERP5Type.patches import PythonScript -from Products.ERP5Type.patches import iHotfix # for python2.3 compatibility import threading diff --git a/product/ERP5Type/patches/iHotfix.py b/product/ERP5Type/patches/iHotfix.py deleted file mode 100644 index 375ffa942c18c856cd2cf6fac1489b01cfa874ed..0000000000000000000000000000000000000000 --- a/product/ERP5Type/patches/iHotfix.py +++ /dev/null @@ -1,9 +0,0 @@ -from Products import iHotfix - -from Products.PageTemplates.PageTemplate import PageTemplate -from TAL.TALInterpreter import TALInterpreter, FasterStringIO - -# revert iHotfix patch that forces PageTemplate to output a string instead of -# a unicode object -TALInterpreter.StringIO = FasterStringIO -PageTemplate.StringIO = FasterStringIO diff --git a/product/ERP5Type/tests/ERP5TypeTestCase.py b/product/ERP5Type/tests/ERP5TypeTestCase.py index 02e66e202f59c7662221ed55335b45b0957ed8b5..b52bb6d8ea5288c5a83980e09ae82f3bcaeae784 100644 --- a/product/ERP5Type/tests/ERP5TypeTestCase.py +++ b/product/ERP5Type/tests/ERP5TypeTestCase.py @@ -75,7 +75,26 @@ ZopeTestCase.installProduct('MailHost', quiet=install_product_quiet) ZopeTestCase.installProduct('PageTemplates', quiet=install_product_quiet) ZopeTestCase.installProduct('PythonScripts', quiet=install_product_quiet) ZopeTestCase.installProduct('ExternalMethod', quiet=install_product_quiet) -ZopeTestCase.installProduct('iHotfix', quiet=install_product_quiet) +try: + # Workaround iHotFix patch that doesn't work with + # ZopeTestCase REQUESTs + ZopeTestCase.installProduct('iHotfix', quiet=install_product_quiet) + from Products import iHotfix + from types import UnicodeType + # revert monkey patchs from iHotfix + iHotfix.get_request = get_request + + originalStringIO = iHotfix.originalStringIO + class UnicodeSafeStringIO(originalStringIO): + """StringIO like class which never fails with unicode.""" + def write(self, s): + if isinstance(s, UnicodeType): + s = s.encode('utf8', 'repr') + originalStringIO.write(self, s) + # iHotFix will patch PageTemplate StringIO with + iHotfix.iHotfixStringIO = UnicodeSafeStringIO +except ImportError: + pass ZopeTestCase.installProduct('Localizer', quiet=install_product_quiet) ZopeTestCase.installProduct('TimerService', quiet=install_product_quiet)