Commit a4dc8372 authored by Julien Muchembled's avatar Julien Muchembled

Move some compatibility code for Python 2.4 into a single place

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41940 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 90c019e3
......@@ -27,13 +27,10 @@
##############################################################################
import cPickle, sys
from hashlib import sha1 as sha_new
from DateTime import DateTime
from zLOG import LOG, WARNING, ERROR
from ZODB.POSException import ConflictError
try:
from hashlib import sha1 as sha_new
except ImportError:
from sha import new as sha_new
from cStringIO import StringIO
import transaction
......
......@@ -28,6 +28,7 @@
##############################################################################
import StringIO
from hashlib import md5 as md5_new
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type import Permissions, PropertySheet
......@@ -40,11 +41,6 @@ from OFS.DTMLDocument import DTMLDocument
from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.Core.ActionInformation import CacheableAction
try:
from hashlib import md5 as md5_new
except ImportError:
from md5 import new as md5_new
def getPropertiesCSSDict(parsed_scribus
, page_gap
, image_width
......
......@@ -27,10 +27,7 @@
#
##############################################################################
try:
from hashlib import md5 as md5_new
except ImportError:
from md5 import new as md5_new
from hashlib import md5 as md5_new
import string
from Acquisition import aq_base
......
......@@ -50,11 +50,7 @@ from Products.ERP5Type.Globals import InitializeClass, get_request
from Products.PythonScripts.Utility import allow_class
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from warnings import warn
try:
from hashlib import md5 as md5_new
except ImportError:
from md5 import new as md5_new
from hashlib import md5 as md5_new
import cgi
DEFAULT_LISTBOX_DISPLAY_STYLE = 'table'
......
......@@ -41,10 +41,7 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5Form import _dtmldir
from Products.ERP5Form.Selection import Selection, DomainSelection
from ZPublisher.HTTPRequest import FileUpload
try:
from hashlib import md5 as md5_new
except ImportError:
from md5 import new as md5_new
from hashlib import md5 as md5_new
import string, re
from time import time
from random import random
......
......@@ -36,15 +36,7 @@ import warnings
import sys
import inspect
import persistent
try:
# Python 2.5 or later
from hashlib import md5 as md5_new
from hashlib import sha1 as sha_new
except ImportError:
# Python 2.4
from md5 import new as md5_new
from sha import new as sha_new
from hashlib import md5 as md5_new, sha1 as sha_new
from Products.ERP5Type.Globals import package_home
from Products.ERP5Type.Globals import DevelopmentMode
from Acquisition import aq_base
......
......@@ -67,7 +67,6 @@ from Products.ERP5Type.patches import ZODBConnection
# dropped support for older versions.
from Products.ERP5Type.patches import TransactionAddBeforeCommitHook
from Products.ERP5Type.patches import ZopePageTemplate
from Products.ERP5Type.patches import re_patch
# These symbols are required for backward compatibility
from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager
......
......@@ -30,6 +30,7 @@
ERP5Type is provides a RAD environment for Zope / CMF
All ERP5 classes derive from ERP5Type
"""
from patches import python
from zLOG import LOG, INFO
DISPLAY_BOOT_PROCESS = False
......
......@@ -26,23 +26,49 @@
#
##############################################################################
# A business template exported by Python 2.4 may contain:
# <klass>
# <global id="xxx" name="_compile" module="sre"/>
# </klass>
#
# A business template exported by Python 2.6 may contain:
# <klass>
# <global id="xxx" name="_compile" module="re"/>
# </klass>
#
# Python 2.6 provides 'sre._compile', but Python 2.4 does not provide
# 're._compile', so we provide re._compile here for the backward
# compatilibility.
import sys
if sys.version_info < (2, 5):
import __builtin__, imp
def all(iterable):
"""
Return True if bool(x) is True for all values x in the iterable.
"""
for x in iterable:
if not x:
return False
return True
__builtin__.all = all
def any(iterable):
"""
Return True if bool(x) is True for any x in the iterable.
"""
for x in iterable:
if x:
return True
return False
__builtin__.any = any
import md5, sha
sys.modules['hashlib'] = hashlib = imp.new_module('hashlib')
hashlib.md5 = md5.new
hashlib.sha1 = sha.new
# A business template exported by Python 2.4 may contain:
# <klass>
# <global id="xxx" name="_compile" module="sre"/>
# </klass>
#
# A business template exported by Python 2.6 may contain:
# <klass>
# <global id="xxx" name="_compile" module="re"/>
# </klass>
#
# Python 2.6 provides 'sre._compile', but Python 2.4 does not provide
# 're._compile', so we provide re._compile here for the backward
# compatilibility.
import re
if not hasattr(re, '_compile'):
import sre
import re, sre
re._compile = sre._compile
del sre
del re
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