[Checkins] SVN: keas.kmi/trunk/ Fixed deprecation warnings about md5 and zope.testing.doctest.

Marius Gedminas marius at pov.lt
Fri Aug 27 14:07:11 EDT 2010


Log message for revision 115969:
  Fixed deprecation warnings about md5 and zope.testing.doctest.
  
  

Changed:
  U   keas.kmi/trunk/CHANGES.txt
  U   keas.kmi/trunk/setup.py
  U   keas.kmi/trunk/src/keas/kmi/README.txt
  U   keas.kmi/trunk/src/keas/kmi/facility.py
  U   keas.kmi/trunk/src/keas/kmi/testing.py
  U   keas.kmi/trunk/src/keas/kmi/tests.py

-=-
Modified: keas.kmi/trunk/CHANGES.txt
===================================================================
--- keas.kmi/trunk/CHANGES.txt	2010-08-27 09:16:12 UTC (rev 115968)
+++ keas.kmi/trunk/CHANGES.txt	2010-08-27 18:07:11 UTC (rev 115969)
@@ -2,10 +2,10 @@
 CHANGES
 =======
 
-1.2.0 (unreleased)
+1.1.1 (unreleased)
 ------------------
 
-- No changes yet.
+- Fixed deprecation warnings about md5 and zope.testing.doctest.
 
 1.1.0 (2010-08-25)
 ------------------

Modified: keas.kmi/trunk/setup.py
===================================================================
--- keas.kmi/trunk/setup.py	2010-08-27 09:16:12 UTC (rev 115968)
+++ keas.kmi/trunk/setup.py	2010-08-27 18:07:11 UTC (rev 115969)
@@ -22,7 +22,7 @@
 
 setup (
     name='keas.kmi',
-    version='1.2.0dev',
+    version='1.1.1dev',
     author = "Stephan Richter and the Zope Community",
     author_email = "zope-dev at zope.org",
     description = "A Key Management Infrastructure",

Modified: keas.kmi/trunk/src/keas/kmi/README.txt
===================================================================
--- keas.kmi/trunk/src/keas/kmi/README.txt	2010-08-27 09:16:12 UTC (rev 115968)
+++ keas.kmi/trunk/src/keas/kmi/README.txt	2010-08-27 18:07:11 UTC (rev 115969)
@@ -61,9 +61,11 @@
 
 You can now use this key encrypting key to extract the encryption keys:
 
-  >>> import md5
-  >>> hash = md5.new()
-  >>> hash.update(key)
+  >>> try:
+  ...    from hashlib import md5
+  ... except ImportError:
+  ...    from md5 import md5
+  >>> hash = md5(key)
 
   >>> keys.get(hash.hexdigest())
   <Key ...>
@@ -191,8 +193,7 @@
 The operation is forwarded to the master server, so that the key is available
 there as well:
 
-  >>> hash = md5.new()
-  >>> hash.update(key2)
+  >>> hash = md5(key2)
 
   >>> hash.hexdigest() in keys
   True
@@ -227,8 +228,7 @@
 
 The key is available in the facility of course:
 
-  >>> hash = md5.new()
-  >>> hash.update(key3)
+  >>> hash = md5(key3)
 
   >>> hash.hexdigest() in keys
   True

Modified: keas.kmi/trunk/src/keas/kmi/facility.py
===================================================================
--- keas.kmi/trunk/src/keas/kmi/facility.py	2010-08-27 09:16:12 UTC (rev 115968)
+++ keas.kmi/trunk/src/keas/kmi/facility.py	2010-08-27 18:07:11 UTC (rev 115969)
@@ -17,11 +17,16 @@
 """
 from __future__ import absolute_import
 __docformat__ = "reStructuredText"
+
+import datetime
+import time
+try:
+    from hashlib import md5
+except ImportError:
+    from md5 import md5
+
 import M2Crypto
-import datetime
-import md5
 import persistent
-import time
 import zope.interface
 import zope.location
 from z3c.rest import client
@@ -29,8 +34,10 @@
 from zope.container import btree
 from zope.dublincore import property
 from zope.schema.fieldproperty import FieldProperty
+
 from keas.kmi import interfaces
 
+
 class Key(zope.location.Location, persistent.Persistent):
     zope.interface.implements(interfaces.IKey, IAttributeAnnotatable)
 
@@ -106,7 +113,7 @@
         # 3. Generate the encryption key
         key = M2Crypto.Rand.rand_bytes(self.keyLength)
         # 4. Create the lookup key in the container
-        hash = md5.new()
+        hash = md5()
         hash.update(privateKey)
         # 5. Save the encryption key
         encryptedKey = rsa.public_encrypt(key, self.rsaPadding)
@@ -117,7 +124,7 @@
     def getEncryptionKey(self, key):
         """Given the key encrypting key, get the encryption key."""
         # 1. Create the lookup key in the container
-        hash = md5.new()
+        hash = md5()
         hash.update(key)
         # 2. Extract the encrypted encryption key
         encryptedKey = self[hash.hexdigest()].key

Modified: keas.kmi/trunk/src/keas/kmi/testing.py
===================================================================
--- keas.kmi/trunk/src/keas/kmi/testing.py	2010-08-27 09:16:12 UTC (rev 115968)
+++ keas.kmi/trunk/src/keas/kmi/testing.py	2010-08-27 18:07:11 UTC (rev 115969)
@@ -14,10 +14,16 @@
 """
 $Id$
 """
-import md5
+
 import cStringIO
+try:
+    from hashlib import md5
+except ImportError:
+    from md5 import md5
+
 from zope.publisher import browser
 from zope.interface import implements
+
 from keas.kmi import facility, rest, interfaces
 
 KeyEncyptingKey = '''-----BEGIN RSA PRIVATE KEY-----
@@ -72,9 +78,7 @@
 
     def __init__(self):
         super(TestingKeyManagementFacility, self).__init__()
-        hash = md5.new()
-        hash.update(KeyEncyptingKey)
-        md5Key = hash.hexdigest()
+        md5Key = md5(KeyEncyptingKey).hexdigest()
         self[md5Key] = facility.Key(EncryptedEncryptionKey)
 
     def generate(self):

Modified: keas.kmi/trunk/src/keas/kmi/tests.py
===================================================================
--- keas.kmi/trunk/src/keas/kmi/tests.py	2010-08-27 09:16:12 UTC (rev 115968)
+++ keas.kmi/trunk/src/keas/kmi/tests.py	2010-08-27 18:07:11 UTC (rev 115969)
@@ -15,9 +15,9 @@
 $Id$
 """
 import unittest
+import doctest
 
 import transaction
-from zope.testing import doctest
 from zope.app.testing import setup
 from zope.component import provideUtility
 from zope.interface.verify import verifyObject



More information about the checkins mailing list