[Erp5-report] r38305 leonardo - in /erp5/trunk/products/ERP5Type: ./ patches/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Sep 13 15:38:29 CEST 2010


Author: leonardo
Date: Mon Sep 13 15:38:26 2010
New Revision: 38305

URL: http://svn.erp5.org?rev=38305&view=rev
Log:
Add support for ZPTs saved in business templates under Zope 2.12

Added:
    erp5/trunk/products/ERP5Type/patches/ZopePageTemplate.py
Modified:
    erp5/trunk/products/ERP5Type/ZopePatch.py

Modified: erp5/trunk/products/ERP5Type/ZopePatch.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ZopePatch.py?rev=38305&r1=38304&r2=38305&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ZopePatch.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/ZopePatch.py [utf8] Mon Sep 13 15:38:26 2010
@@ -64,6 +64,7 @@ from Products.ERP5Type.patches import De
 # 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

Added: erp5/trunk/products/ERP5Type/patches/ZopePageTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/ZopePageTemplate.py?rev=38305&view=auto
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/ZopePageTemplate.py (added)
+++ erp5/trunk/products/ERP5Type/patches/ZopePageTemplate.py [utf8] Mon Sep 13 15:38:26 2010
@@ -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 at 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__
+
+




More information about the Erp5-report mailing list