app/django/db/backends/util.py
changeset 323 ff1a9aa48cfd
parent 54 03e267d67478
--- a/app/django/db/backends/util.py	Tue Oct 14 12:36:55 2008 +0000
+++ b/app/django/db/backends/util.py	Tue Oct 14 16:00:59 2008 +0000
@@ -1,7 +1,8 @@
 import datetime
-import md5
 from time import time
 
+from django.utils.hashcompat import md5_constructor
+
 try:
     import decimal
 except ImportError:
@@ -114,6 +115,13 @@
     if length is None or len(name) <= length:
         return name
 
-    hash = md5.md5(name).hexdigest()[:4]
+    hash = md5_constructor(name).hexdigest()[:4]
 
     return '%s%s' % (name[:length-4], hash)
+
+def format_number(value, max_digits, decimal_places):
+    """
+    Formats a number into a string with the requisite number of digits and
+    decimal places.
+    """
+    return u"%.*f" % (decimal_places, value)