Commit e2e5a515 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

remove DeprecationWarning on python-2.6.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39452 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2e536fb2
......@@ -40,7 +40,10 @@ from OFS.DTMLDocument import DTMLDocument
from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.Core.ActionInformation import CacheableAction
import md5
try:
from hashlib import md5 as md5_new
except ImportError:
from md5 import new as md5_new
def getPropertiesCSSDict(parsed_scribus
, page_gap
......@@ -432,7 +435,7 @@ class PDFTypeInformation(ERP5TypeInformation):
generateParsedScribus = CachingMethod(generateParsedScribus,
('PDFTypeInformation_generateParsedScribus',
md5.new(scribus_form.getData()).digest()),
md5_new(scribus_form.getData()).digest()),
cache_factory='dms_cache_factory')
return generateParsedScribus()
......@@ -545,7 +548,7 @@ class PDFTypeInformation(ERP5TypeInformation):
return form
#generateERP5Form = CachingMethod(generateERP5Form,
# ('PDFTypeInformation_generateERP5Form',
# md5.new(self.getDefaultScribusFormValue().getData()).digest()),
# md5_new(self.getDefaultScribusFormValue().getData()).digest()),
# cache_factory='dms_cache_factory')
return generateERP5Form().__of__(self)
......@@ -595,7 +598,7 @@ class PDFTypeInformation(ERP5TypeInformation):
generateERP5FormCSS = CachingMethod(generateERP5FormCSS,
('PDFTypeInformation_generateERP5FormCSS',
md5.new(self.getDefaultScribusFormValue().getData()).digest()),
md5_new(self.getDefaultScribusFormValue().getData()).digest()),
cache_factory='dms_cache_factory')
self.REQUEST.RESPONSE.setHeader('Content-Type', 'text/css')
return generateERP5FormCSS()
......
......@@ -31,7 +31,10 @@ import cStringIO
import re
import string
import socket
import md5
try:
from hashlib import md5 as md5_new
except ImportError:
from md5 import new as md5_new
import urllib2, urllib
import urlparse
from cgi import parse_header
......@@ -511,7 +514,7 @@ class ContributionTool(BaseTool):
is simimar in cost to accessing them.
"""
# Produce an MD5 from the URL
hex_md5 = md5.md5(url).hexdigest()
hex_md5 = md5_new(url).hexdigest()
# Take the first part in the URL which is not empty
# LOG("encodeURL", 0, url)
url_segment = url.split(':')[1]
......@@ -614,7 +617,7 @@ class ContributionTool(BaseTool):
# Step 2: compare and update if necessary (md5)
# md5 stuff to compare contents
new_content_md5 = md5.md5(data).hexdigest()
new_content_md5 = md5_new(data).hexdigest()
content_md5 = content.getContentMd5()
if content_md5 == new_content_md5:
return
......
......@@ -27,7 +27,10 @@
#
##############################################################################
import md5
try:
from hashlib import md5 as md5_new
except ImportError:
from md5 import new as md5_new
import string
from Acquisition import aq_base
......@@ -48,7 +51,7 @@ def hashPdataObject(pdata_object):
"""Pdata objects are iterable, use this feature strongly
to minimize memory footprint.
"""
md5_hash = md5.new()
md5_hash = md5_new()
next = pdata_object
while next is not None:
md5_hash.update(next.data)
......@@ -134,11 +137,11 @@ class CachedConvertableMixin:
size = len(cached_value)
elif isinstance(data, OFSImage):
cached_value = data
conversion_md5 = md5.new(str(data.data)).hexdigest()
conversion_md5 = md5_new(str(data.data)).hexdigest()
size = len(data.data)
else:
cached_value = data
conversion_md5 = md5.new(cached_value).hexdigest()
conversion_md5 = md5_new(cached_value).hexdigest()
size = len(cached_value)
if date is None:
date = DateTime()
......@@ -238,7 +241,7 @@ class CachedConvertableMixin:
if isinstance(data, Pdata):
self._setContentMd5(hashPdataObject(aq_base(data)))
else:
self._setContentMd5(md5.new(data).hexdigest()) # Reindex is useless
self._setContentMd5(md5_new(data).hexdigest()) # Reindex is useless
else:
self._setContentMd5(None)
......
......@@ -51,7 +51,10 @@ from Products.PythonScripts.Utility import allow_class
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from warnings import warn
import md5
try:
from hashlib import md5 as md5_new
except ImportError:
from md5 import new as md5_new
import cgi
DEFAULT_LISTBOX_DISPLAY_STYLE = 'table'
......@@ -2565,7 +2568,7 @@ class ListBoxHTMLRenderer(ListBoxRenderer):
if checked_uid_list is not None:
checked_uid_list = [str(uid) for uid in checked_uid_list]
checked_uid_list.sort()
md5_string = md5.new(str(checked_uid_list)).hexdigest()
md5_string = md5_new(str(checked_uid_list)).hexdigest()
else:
md5_string = None
......
......@@ -41,7 +41,10 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5Form import _dtmldir
from Products.ERP5Form.Selection import Selection, DomainSelection
from ZPublisher.HTTPRequest import FileUpload
import md5
try:
from hashlib import md5 as md5_new
except ImportError:
from md5 import new as md5_new
import string, re
from time import time
from random import random
......@@ -1150,7 +1153,7 @@ class SelectionTool( BaseTool, SimpleItem ):
# convert each element to a string.
object_uid_list = [str(x) for x in object_uid_list]
object_uid_list.sort()
new_md5_string = md5.new(str(object_uid_list)).hexdigest()
new_md5_string = md5_new(str(object_uid_list)).hexdigest()
return md5_string != new_md5_string
......@@ -1390,7 +1393,7 @@ class SelectionTool( BaseTool, SimpleItem ):
if user_id == 'Anonymous User' and self.getAnonymousStorage() is not None:
anonymous_uid = self.REQUEST.get('anonymous_uid', None)
if anonymous_uid is None:
anonymous_uid = md5.new('%s.%s' % (time(), random())).hexdigest()
anonymous_uid = md5_new('%s.%s' % (time(), random())).hexdigest()
self.REQUEST['anonymous_uid'] = anonymous_uid
user_id = 'Anonymous:%s' % anonymous_uid
tv['_user_id'] = user_id
......
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