[Erp5-report] r39451 kazuhiko - in /erp5/trunk/products/ERP5: Document/ mixin/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Oct 21 21:19:05 CEST 2010


Author: kazuhiko
Date: Thu Oct 21 21:19:03 2010
New Revision: 39451

URL: http://svn.erp5.org?rev=39451&view=rev
Log:
remove DeprecationWarning on python-2.6.

Modified:
    erp5/trunk/products/ERP5/Document/PDFTypeInformation.py
    erp5/trunk/products/ERP5/mixin/cached_convertable.py

Modified: erp5/trunk/products/ERP5/Document/PDFTypeInformation.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PDFTypeInformation.py?rev=39451&r1=39450&r2=39451&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PDFTypeInformation.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/PDFTypeInformation.py [utf8] Thu Oct 21 21:19:03 2010
@@ -40,7 +40,10 @@ from OFS.DTMLDocument import DTMLDocumen
 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(ERP5TypeInforma
 
     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(ERP5TypeInforma
       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(ERP5TypeInforma
 
     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()

Modified: erp5/trunk/products/ERP5/mixin/cached_convertable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/cached_convertable.py?rev=39451&r1=39450&r2=39451&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/cached_convertable.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/cached_convertable.py [utf8] Thu Oct 21 21:19:03 2010
@@ -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)
 




More information about the Erp5-report mailing list