--- a/utils.py Fri Sep 18 11:06:42 2009 +0200
+++ b/utils.py Fri Sep 18 12:20:39 2009 +0200
@@ -10,13 +10,14 @@
from logilab.mtconverter import xml_escape
import locale
+import sys
+import decimal
+import datetime as pydatetime
from md5 import md5
-import datetime as pydatetime
from datetime import datetime, timedelta, date
from time import time, mktime
from random import randint, seed
from calendar import monthrange
-import decimal
import simplejson
@@ -107,11 +108,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 str(key) + str(uuid4())
def dump_class(cls, clsname):
"""create copy of a class by creating an empty class inheriting