Commit aaa8483d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

these patches are no longer required because Zope 2.7 is no longer supported.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25552 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3afe594c
......@@ -25,7 +25,6 @@ from Products.ERP5Type.patches import PropertyManager
from Products.ERP5Type.patches import DA
from Products.ERP5Type.patches import DCWorkflow
from Products.ERP5Type.patches import BTreeFolder2
from Products.ERP5Type.patches import Transaction
from Products.ERP5Type.patches import WorkflowTool
from Products.ERP5Type.patches import XMLExportImport
from Products.ERP5Type.patches import ppml
......@@ -47,14 +46,10 @@ from Products.ERP5Type.patches import CMFCoreSkinnable
from Products.ERP5Type.patches import CMFCoreSkinsTool
from Products.ERP5Type.patches import CMFBTreeFolder
from Products.ERP5Type.patches import OFSFolder
from Products.ERP5Type.patches import Connection
from Products.ERP5Type.patches import copy_reg_patch
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 MailTemplates
from Products.ERP5Type.patches import persistent_patch
from Products.ERP5Type.patches import http_server
# These symbols are required for backward compatibility
......
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2007 Nexedi SA
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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
#
##############################################################################
"""This patch is for importing Business Templates generated by Zope 2.8
into Zope 2.7.
In Zope 2.7, the class of an object was represented by a tuple (module, name),
but this has been changed to just a class name itself.
"""
try:
# This portion depends on ZODB, so the version test is based on
# the ZODB's structure. In ZODB 3.4 and later, the object serialization
# is segregated to serialize.py, while it is in Connection.py in ZODB 3.2.
from ZODB import serialize
del serialize
except ImportError:
from ZODB.Connection import Connection, StringIO, Unpickler, ExtensionKlass
def __getitem__(self, oid, tt=type(())):
obj = self._cache.get(oid, None)
if obj is not None:
return obj
__traceback_info__ = (oid)
p, serial = self._storage.load(oid, self._version)
__traceback_info__ = (oid, p)
file=StringIO(p)
unpickler=Unpickler(file)
unpickler.persistent_load=self._persistent_load
object = unpickler.load()
# <patch author="yo">
if type(object) is tt:
klass, args = object
else:
klass = object
args = None
# </patch>
if type(klass) is tt:
module, name = klass
klass=self._db._classFactory(self, module, name)
if (args is None or
not args and not hasattr(klass,'__getinitargs__')):
object=klass.__basicnew__()
else:
object = klass(*args)
if klass is not ExtensionKlass:
object.__dict__.clear()
object._p_oid=oid
object._p_jar=self
object._p_changed=None
object._p_serial=serial
self._cache[oid] = object
return object
Connection.__getitem__ = __getitem__
##############################################################################
#
# Copyright (c) 2007 Nexedi SARL and Contributors. All Rights Reserved.
#
# 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 program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
# Add compatibility for importing business template generated from
# Zope 2.8 in Zope 2.7
try:
from Persistence import mapping
except ImportError:
import Persistence
from PersistentMapping import PersistentMapping
import imp
import sys
Persistence.mapping = imp.new_module('Persistence.mapping')
sys.modules['Persistence.mapping'] = Persistence.mapping
Persistence.mapping.PersistentMapping = PersistentMapping
############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# Copyright (c) 2002,2005,2007 Nexedi SA and Contributors.
# All Rights Reserved.
#
# 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.
#
############################################################################
# Add beforeCommitHook into Transaction under Zope 2.7. This API is compatible
# with Zope 2.8.
try:
from ZODB.Transaction import Transaction
super__commit = Transaction.commit
super__init = Transaction.__init__
def __init__(self, *args, **kw):
super__init(self, *args, **kw)
self._before_commit = []
def commit(self, subtransaction=None):
"""Finalize the transaction."""
if not subtransaction:
self._callBeforeCommitHooks()
return super__commit(self, subtransaction=subtransaction)
def beforeCommitHook(self, hook, *args, **kws):
self._before_commit.append((hook, args, kws))
def _callBeforeCommitHooks(self):
# Call all hooks registered, allowing further registrations
# during processing.
while self._before_commit:
hook, args, kws = self._before_commit.pop(0)
hook(*args, **kws)
from new import instancemethod
Transaction.__init__ = instancemethod(__init__, None, Transaction)
Transaction.commit = instancemethod(commit, None, Transaction)
Transaction.beforeCommitHook = instancemethod(beforeCommitHook, None,
Transaction)
Transaction._callBeforeCommitHooks = instancemethod(_callBeforeCommitHooks,
None, Transaction)
except ImportError:
# On Zope 2.8, do not patch Transaction.
pass
##############################################################################
#
# Copyright (c) 2007 Nexedi SA and Contributors. All Rights Reserved.
# Yoshinori Okuji <yo@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 program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
"""This is another patch for importing Business Templates generated by Zope 2.8
into Zope 2.7. Also, look at Connection.py for the other part.
In Zope 2.8 (i.e. ZODB 3.4), persistent objects are based on new-style class,
while Zope 2.7 (i.e. ZODB 3.2) uses old-style class only. To instantiate
objects in ZODB 3.4 and later, copy_reg.__newobj__ is utilized, which
supports only new-style class. On the other hand, ZODB 3.2 makes an empty
object by calling the class object with None.
However, this is based on the analysis of some observation, and theoretically
not very certain. There might be an occasion where non-None arguments are
used to instantiate a ghost object. I am not sure. If this is not true,
we must patch __newobj__ differently.
Note that this file is named copy_reg_patch instead of copy_reg by intention.
Otherwise, importing copy_reg results in importing itself. SO DO NOT RENAME
THIS FILE TO copy_reg.py.
"""
try:
from ZODB import serialize
del serialize
except ImportError:
import copy_reg
original_newobj = copy_reg.__newobj__
def __newobj__(cls, *args):
# If this method is used for new-style class, call the original.
# Otherwise, just call the class object with None.
if issubclass(cls, object):
return original_newobj(cls, *args)
return cls(None)
copy_reg.__newobj__ = __newobj__
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# TAHARA Yusei <yusei@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 program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
# This patch provides forward compatibility between 2.7 and 2.8.
try:
import persistent
except ImportError:
import sys
import types
from ZODB import PersistentList
persistent = types.ModuleType('persistent')
persistent.list = PersistentList
sys.modules['persistent'] = persistent
sys.modules['persistent.list'] = persistent.list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment