Commit 742d237c authored by Julien Muchembled's avatar Julien Muchembled

Drop support for Zope < 2.13

parent 7f1a4034
......@@ -27,7 +27,6 @@
##############################################################################
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import to_utf8
class TestContentTranslation(ERP5TypeTestCase):
......@@ -208,8 +207,9 @@ class TestContentTranslation(ERP5TypeTestCase):
self.tic()
self.assert_('タハラ' in to_utf8(person.Base_viewContentTranslation()))
self.assert_('ユウセイ' in to_utf8(person.Base_viewContentTranslation()))
x = person.Base_viewContentTranslation().encode('utf-8')
self.assertTrue('タハラ' in x)
self.assertTrue('ユウセイ' in x)
self.assertEqual(person.getJaKanaTranslatedFirstName(), 'タハラ')
self.assertEqual(person.getJaKanaTranslatedLastName(), 'ユウセイ')
......
......@@ -34,7 +34,6 @@ import unittest
from AccessControl.SecurityManagement import newSecurityManager
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import to_utf8
class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
"""
......@@ -128,7 +127,7 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
text_content -- the embedded text content
"""
html_text = to_utf8(html_text)
html_text = html_text.encode('utf-8')
match_string1 = "var oFCKeditor = new FCKeditor('field_%s');" % field_id
match_string2 = "oFCKeditor.Value = '%s';" % ('\\n'.join(text_content.splitlines()))
if html_text.find(match_string1) == -1:
......@@ -153,7 +152,7 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
text_content -- the embedded text content
"""
html_text = to_utf8(html_text)
html_text = html_text.encode('utf-8')
match_string = """name="field_%s" >\n%s</textarea>""" % (field_id, text_content)
if html_text.find(match_string) == -1:
print html_text
......@@ -172,7 +171,7 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
document -- the document which content is displayed in
read only mode
"""
html_text = to_utf8(html_text)
html_text = html_text.encode('utf-8')
text_content = document.asStrippedHTML()
match_string1 = """<div class="input"><div class="page" >\n%s</div></div>""" % text_content
match_string2 = """<div class="field page"""
......
......@@ -31,7 +31,6 @@ import unittest
import MethodObject
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import to_utf8
from Products.ERP5Type.Utils import getMessageIdWithContext
from zLOG import LOG
......@@ -440,8 +439,7 @@ class TestTranslation(ERP5TypeTestCase):
</tal:ommit>
""" % domain
self.myzpt.pt_edit(zpt_template, 'text/html')
results = to_utf8(self.myzpt(words=words)).split()
return results
return self.myzpt(words=words).encode('utf-8').split()
def test_ZPT_translation(self):
results = self.translate_by_zpt('erp5_ui', 'Person', 'Draft')
......
......@@ -445,10 +445,8 @@ class W3Validator(object):
'''
retrun two list : a list of errors and an other for warnings
'''
if isinstance(page_source, unicode):
# Zope 2.12 renders page templates as unicode
page_source = page_source.encode('utf-8')
source = 'fragment=%s&output=soap12' % urllib.quote_plus(page_source)
source = 'fragment=%s&output=soap12' % urllib.quote_plus(
page_source.encode('utf-8'))
stdout, stderr = Popen(self.validator_path,
stdin=PIPE, stdout=PIPE, stderr=PIPE,
close_fds=True,
......
......@@ -74,10 +74,8 @@ class ComponentTool(BaseTool):
is called on Portal Type class when loading Componet Tool Portal Type
class
"""
# XXX-Cosmetic: From Zope >= 2.13, getPermissions() can be used instead of
# protected _registeredPermissions module attribute
from AccessControl.Permission import _registeredPermissions, pname
for permission_name in _registeredPermissions:
from AccessControl.Permission import getPermissions, pname
for permission_name, _, _ in getPermissions():
if permission_name == 'Reset dynamic classes':
permission_function = lambda self: ('Manager',)
elif permission_name in ('Change permissions', 'Define permissions'):
......
......@@ -30,8 +30,6 @@ class DemoStorage(_DemoStorage.DemoStorage, ConflictResolvingStorage):
except ConflictError, e:
old = e.serials[0]
rdata = self.tryToResolveConflict(oid, old, serial, data)
if rdata is None: # BBB: Zope < 2.13
raise ConflictError(oid=oid, serials=(old, serial), data=data)
self.changes.store(oid, old, rdata, '', transaction)
return ResolvedSerial
......
......@@ -66,23 +66,9 @@ elif save and not (neo_storage or zeo_client) and os.path.exists(data_fs_path):
zeo_server_pid = None
node_pid_list = []
ZEvent = sys.modules.get('ZServer.PubCore.ZEvent')
zrpc = sys.modules.get('ZEO.zrpc.connection')
def fork():
pid = os.fork()
if pid:
# recreate event pipes that already exist
# BBB: This is useless on Zope 2.13+ since ZEO now imports cleanly.
for obj in socket_map.values():
obj.close()
if obj is ZEvent.the_trigger:
ZEvent.the_trigger = ZEvent.simple_trigger()
else:
assert obj is zrpc.ManagedServerConnection.trigger
zrpc.ManagedServerConnection.trigger = zrpc.trigger()
zrpc.ManagedClientConnection.trigger.close()
zrpc.ManagedClientConnection.trigger = \
zrpc.client_trigger = zrpc.trigger(zrpc.client_map)
# make sure parent and child have 2 different RNG
instance_random.seed(instance_random.random())
return pid
......
......@@ -448,16 +448,6 @@ class LogInterceptor:
handler.removeFilter(self)
self.installed = tuple([s for s in self.installed if s != subsystem])
def to_utf8(text):
""" Converts string to utf-8 if string is unicode """
# BACK: The users of this function are probably reading the result of
# PageTemplate rendering, which is unicode in Zope 2.12, but string in Zope
# 2.8. When support for Zope 2.8 is dropped, rewrite the tests to assume
# the rendering is unicode and deal with it appropriately.
if isinstance(text, unicode):
text = text.encode('utf-8')
return text
def updateCellList(portal, line, cell_type, cell_range_method, cell_dict_list):
"""A matrixbox-like helper function to create cells at once.
......
......@@ -11,11 +11,7 @@ from OFS.Folder import Folder
from Persistence import PersistentMapping
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.permissions import ManagePortal, View
try:
from Products.CMFCore.utils import registerToolInterface
except ImportError: # BACK: Zope 2.8
registerToolInterface = lambda tool_id, tool_interface: None
from Products.CMFCore.utils import UniqueObject
from Products.CMFCore.utils import registerToolInterface, UniqueObject
from Products.CMFCore.utils import getToolByName
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
......
......@@ -27,10 +27,7 @@ import sys
from zLOG import LOG, INFO
from ldif import LDIFRecordList, is_dn, valid_changetype_dict, CHANGE_TYPES
import ldifvar
try:
from DocumentTemplate.security import RestrictedDTML
except ImportError: # BBB Zope-2.12
from AccessControl.DTML import RestrictedDTML
from DocumentTemplate.security import RestrictedDTML
try:
from AccessControl import getSecurityManager
except ImportError:
......
......@@ -26,10 +26,7 @@ from DocumentTemplate.DT_Util import Eval
from AccessControl.Permission import name_trans
from SQLCatalog import CatalogError
from AccessControl import ClassSecurityInfo
try:
from DocumentTemplate.security import RestrictedDTML
except ImportError: # BBB Zope-2.12
from AccessControl.DTML import RestrictedDTML
from DocumentTemplate.security import RestrictedDTML
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Cache import clearCache
import string, sys
......
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