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