utils.py
branch3.5
changeset 3146 cfc4344023f2
parent 3101 e75ab3635f07
child 3155 14e30e2520d7
--- a/utils.py	Wed Sep 09 17:45:34 2009 +0200
+++ b/utils.py	Wed Sep 09 17:46:30 2009 +0200
@@ -11,6 +11,7 @@
 
 import locale
 from md5 import md5
+import sys
 from datetime import datetime, timedelta, date
 from time import time, mktime
 from random import randint, seed
@@ -103,11 +104,17 @@
     encoding = locale.getpreferredencoding(do_setlocale=False) or 'UTF-8'
     return unicode(date.strftime(str(fmt)), encoding)
 
-def make_uid(key):
-    """forge a unique identifier"""
-    msg = str(key) + "%.10f" % time() + str(randint(0, 1000000))
-    return md5(msg).hexdigest()
 
+if sys.version_info[:2] < (2, 5):
+    def make_uid(key):
+        """forge a unique identifier
+        not that unique on win32"""
+        msg = str(key) + "%.10f" % time() + str(randint(0, 1000000))
+        return md5(msg).hexdigest()
+else:
+    from uuid import uuid4
+    def make_uid(key):
+        return key + str(uuid4())
 
 def dump_class(cls, clsname):
     """create copy of a class by creating an empty class inheriting