Commits

Ralph Bean  committed ae340d0

Made timedelta a param.

  • Participants
  • Parent commits 83295a6

Comments (0)

Files changed (1)

File tw2/rrd/widgets.py

 
     start = twc.Param("Start as a python datetime")
     end = twc.Param("End as a python datetime")
+    timedelta = twc.Param(
+        "Overridden if `start` and `end` are specified.",
+        default=datetime.timedelta(days=365)
+    )
 
     @classmethod
     def file2name(cls, fname):
             cls.end = datetime.datetime.now()
 
         if not hasattr(cls, 'start'):
-            cls.start = cls.end - datetime.timedelta(days=365)
+            cls.start = cls.end - cls.timedelta
 
         if cls.end <= cls.start:
             raise ValueError, "end <= start"
 class RRDFlotWidget(flot.FlotWidget, RRDMixin):
     data = twc.Variable("Internally produced.")
 
-    end = datetime.datetime.now()
-    start = datetime.datetime.now() - datetime.timedelta(days=365)
-
     options = {
         'xaxis' : {
             'mode' : 'time',