--- a/utils.py Fri May 29 19:31:32 2009 +0200
+++ b/utils.py Fri May 29 19:34:00 2009 +0200
@@ -10,7 +10,7 @@
import locale
from md5 import md5
from datetime import datetime, timedelta, date
-from time import time
+from time import time, mktime
from random import randint, seed
from calendar import monthrange
@@ -38,6 +38,9 @@
assert isinstance(somedate, date), repr(somedate)
return datetime(somedate.year, somedate.month, somedate.day)
+def datetime2ticks(date):
+ return mktime(date.timetuple()) * 1000
+
ONEDAY = timedelta(days=1)
ONEWEEK = timedelta(days=7)
@@ -100,7 +103,7 @@
def make_uid(key):
"""forge a unique identifier"""
- msg = str(key) + "%.10f"%time() + str(randint(0, 1000000))
+ msg = str(key) + "%.10f" % time() + str(randint(0, 1000000))
return md5(msg).hexdigest()
--- a/web/views/plots.py Fri May 29 19:31:32 2009 +0200
+++ b/web/views/plots.py Fri May 29 19:34:00 2009 +0200
@@ -15,7 +15,7 @@
from logilab.common import flatten
from logilab.mtconverter import html_escape
-from cubicweb.utils import make_uid, UStringIO
+from cubicweb.utils import make_uid, UStringIO, datetime2ticks
from cubicweb.vregistry import objectify_selector
from cubicweb.web.views import baseviews
@@ -60,9 +60,6 @@
filtered.append( (x, y) )
return sorted(filtered)
-def datetime2ticks(date):
- return time.mktime(date.timetuple()) * 1000
-
class PlotWidget(object):
# XXX refactor with cubicweb.web.views.htmlwidgets.HtmlWidget
def _initialize_stream(self, w=None):