From f2eb310c9b4a21eed66d581d09ad965867333e11 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Fri, 6 May 2011 15:15:00 +0000
Subject: [PATCH] Patch OFS.History.

---
 product/ERP5Type/ZopePatch.py          |  1 +
 product/ERP5Type/patches/OFSHistory.py | 45 ++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 product/ERP5Type/patches/OFSHistory.py

diff --git a/product/ERP5Type/ZopePatch.py b/product/ERP5Type/ZopePatch.py
index 8646eb0c1b..b3d34cd07b 100644
--- a/product/ERP5Type/ZopePatch.py
+++ b/product/ERP5Type/ZopePatch.py
@@ -72,6 +72,7 @@ from Products.ERP5Type.patches import ZODBConnection
 from Products.ERP5Type.patches import TransactionAddBeforeCommitHook
 from Products.ERP5Type.patches import ZopePageTemplate
 from Products.ERP5Type.patches import ZopePageTemplateUtils
+from Products.ERP5Type.patches import OFSHistory
 
 # These symbols are required for backward compatibility
 from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager
diff --git a/product/ERP5Type/patches/OFSHistory.py b/product/ERP5Type/patches/OFSHistory.py
new file mode 100644
index 0000000000..df8904253c
--- /dev/null
+++ b/product/ERP5Type/patches/OFSHistory.py
@@ -0,0 +1,45 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Foundation and Contributors.
+#
+# 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
+#
+##############################################################################
+
+from OFS.History import HystoryJar, historicalRevision
+
+"""
+Rationale for this patch:
+Modifications __setstate__ does to self must not cause object to become
+registered to its jar (ie, it must have no jar).
+
+Original code breaks this, and this makes it impossible to view, for example,
+a former revision of a PythonScript if that revision was written by an old
+Zope (ex: 2.12 reading 2.8 PythonScript).
+
+Launchpad bug opened, patch submitted:
+  https://bugs.launchpad.net/zope2/+bug/735999
+"""
+
+# Original function lines removed by this patch are present but commented-out.
+def patched_historicalRevision(self, serial):
+    state=self._p_jar.oldstate(self, serial)
+    rev=self.__class__.__basicnew__()
+#    rev._p_jar=HystoryJar(self._p_jar)
+    rev._p_oid=self._p_oid
+#    rev._p_serial=serial
+    rev.__setstate__(state)
+#    rev._p_changed=0
+# PATCH ADDITION BEGIN
+    rev._p_serial=serial
+    rev._p_jar=HystoryJar(self._p_jar)
+# PATCH ADDITION END
+    return rev
+
+historicalRevision.func_code = patched_historicalRevision.func_code
+
-- 
2.30.9