diff --git a/product/ERP5Type/ZopePatch.py b/product/ERP5Type/ZopePatch.py index f923caaf5762f5c9b5d17a0eb2892099dadea8f1..261561f40ecf2d8abe7b77a7a03cec9da9b7c77f 100644 --- a/product/ERP5Type/ZopePatch.py +++ b/product/ERP5Type/ZopePatch.py @@ -64,6 +64,7 @@ from Products.ERP5Type.patches import DemoStorage # BACK: Forward Compatibility with Zope 2.12 or CMF 2.2. Remove when we've # dropped support for older versions. from Products.ERP5Type.patches import TransactionAddBeforeCommitHook +from Products.ERP5Type.patches import ZopePageTemplate # These symbols are required for backward compatibility from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager diff --git a/product/ERP5Type/patches/ZopePageTemplate.py b/product/ERP5Type/patches/ZopePageTemplate.py new file mode 100644 index 0000000000000000000000000000000000000000..d12e27a0ca42336e43fc67d9b7cfac3fd9adfd1a --- /dev/null +++ b/product/ERP5Type/patches/ZopePageTemplate.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2002 Zope Foundation and Contributors. +# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved. +# Leonardo Rochael Almeida <leonardo@nexedi.com> +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE +############################################################################## + +# BBB: This whole file is unnecessary once we drop support for Zope 2.8 + +from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate + +marker = object() + +if getattr(ZopePageTemplate, 'output_encoding', marker) is marker: + # pre-Zope 2.10, non-unicode Zope Page Templates. + # downgrade source code and title to utf-8 for compatibility + def __setstate__(self, state): + # Perform on-the-fly migration from unicode. + if isinstance(state.get('_text'), unicode): + state['_text'] = state['_text'].encode('utf-8') + if isinstance(state.get('title'), unicode): + state['title'] = state['title'].encode('utf-8') + ZopePageTemplate.inheritedAttribute('__setstate__')(self, state) + + ZopePageTemplate.__setstate__ = __setstate__ + +