Commit a6e05817 authored by Jérome Perrin's avatar Jérome Perrin

patches: make Shared.DC.Scripts.Bindings and ZPublisher.BeforeTraverse.MultiHook new-style classes

This backports parts of zope commit bb7837c66 (Explicitly make all
classes new-style., 2017-09-15) and 173658008 (Fix unpickling of instances
those base class changed to a new-style class. (#208), 2017-10-24).

This is done for two reasons:
 - so that business template XML are same when exported from zope4
   and from zope2
 - so that a business template created from zope4 can still be
   installed on zope2.
parent 0fbc3f6c
...@@ -110,6 +110,8 @@ from Products.ERP5Type.patches import WSGITask ...@@ -110,6 +110,8 @@ from Products.ERP5Type.patches import WSGITask
if six.PY2: if six.PY2:
# XXX-zope4py3: urllib2 removed (see future/backports/urllib/request.py) # XXX-zope4py3: urllib2 removed (see future/backports/urllib/request.py)
from Products.ERP5Type.patches import urllib_opener from Products.ERP5Type.patches import urllib_opener
from Products.ERP5Type.patches import SharedDCScriptsBindings
from Products.ERP5Type.patches import ZPublisherBeforeTraverse
# These symbols are required for backward compatibility # These symbols are required for backward compatibility
from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager
......
import Shared.DC.Scripts.Bindings
# Make Shared.DC.Scripts.Bindings a new style classes already on Zope2, so that
# we can install business templates exported on Zope4 in Zope2 instances.
_NameAssignments = Shared.DC.Scripts.Bindings.NameAssignments
if not isinstance(_NameAssignments, type):
class NameAssignments(_NameAssignments, object):
def __init__(self, mapping=None):
if mapping is None:
mapping = {}
_NameAssignments.__init__(self, mapping)
NameAssignments.__module__ = _NameAssignments.__module__
Shared.DC.Scripts.Bindings.NameAssignments = NameAssignments
import ZPublisher.BeforeTraverse
# Make ZPublisher.BeforeTraverse.MultiHook a new style classes already on
# Zope2, so that we can install business templates exported on Zope4 in
# Zope2 instances.
_MultiHook = ZPublisher.BeforeTraverse.MultiHook
if not isinstance(_MultiHook, type):
class MultiHook(_MultiHook, object):
def __init__(self, hookname='<undefined hookname>', prior=None,
defined_in_class=False):
_MultiHook.__init__(self, hookname, prior, defined_in_class)
def __repr__(self):
# BBB keep the old class repr for testBeforeTraverse
return '<ZPublisher.BeforeTraverse.MultiHook instance at 0x%0x (patched in %r)>' % (
id(self), __file__)
MultiHook.__module__ = _MultiHook.__module__
ZPublisher.BeforeTraverse.MultiHook = MultiHook
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