[Zope-Checkins] SVN: Zope/trunk/utilities/mkzopeinstance.py Make the SHA usage in mkzopeinstance a conditional import. Re-adds Python2.4 compatibility

Matthew Wilkes matthew at matthewwilkes.co.uk
Sun Oct 26 14:45:58 EDT 2008


Log message for revision 92606:
  Make the SHA usage in mkzopeinstance a conditional import.  Re-adds Python2.4 compatibility

Changed:
  U   Zope/trunk/utilities/mkzopeinstance.py

-=-
Modified: Zope/trunk/utilities/mkzopeinstance.py
===================================================================
--- Zope/trunk/utilities/mkzopeinstance.py	2008-10-26 16:17:13 UTC (rev 92605)
+++ Zope/trunk/utilities/mkzopeinstance.py	2008-10-26 18:45:54 UTC (rev 92606)
@@ -167,9 +167,12 @@
 
 def write_inituser(fn, user, password):
     import binascii
-    import hashlib
+    try:
+        from hashlib import sha256 as sha
+    except:
+        from sha import new as sha
     fp = open(fn, "w")
-    pw = binascii.b2a_base64(hashlib.sha256(password).digest())[:-1]
+    pw = binascii.b2a_base64(sha(password).digest())[:-1]
     fp.write('%s:{SHA256}%s\n' % (user, pw))
     fp.close()
     os.chmod(fn, 0644)



More information about the Zope-Checkins mailing list