Fixed bug that prevented an optional data_binding from being used in tags

when iterating over records. Fixes issue #345.
This commit is contained in:
Tom Keffer
2018-09-27 05:53:55 -07:00
parent 3e516ab944
commit ba86c25429
2 changed files with 16 additions and 13 deletions

View File

@@ -168,40 +168,40 @@ class TimespanBinder(object):
self.option_dict = option_dict
# Iterate over all records in the time period:
def records(self, data_binding=None):
manager = self.db_lookup(data_binding)
def records(self):
manager = self.db_lookup(self.data_binding)
for record in manager.genBatchRecords(self.timespan.start, self.timespan.stop):
yield CurrentObj(self.db_lookup, None, record['dateTime'], self.formatter,
yield CurrentObj(self.db_lookup, self.data_binding, record['dateTime'], self.formatter,
self.converter, record=record)
# Iterate over custom span
def spans(self, data_binding=None, context='day', interval=10800):
def spans(self, context='day', interval=10800):
for span in weeutil.weeutil.intervalgen(self.timespan.start, self.timespan.stop, interval):
yield TimespanBinder(span, self.db_lookup, data_binding,
yield TimespanBinder(span, self.db_lookup, self.data_binding,
context, self.formatter, self.converter, **self.option_dict)
# Iterate over hours in the time period:
def hours(self, data_binding=None):
def hours(self):
return TimespanBinder._seqGenerator(weeutil.weeutil.genHourSpans, self.timespan,
self.db_lookup, data_binding,
self.db_lookup, self.data_binding,
'hour', self.formatter, self.converter, **self.option_dict)
# Iterate over days in the time period:
def days(self, data_binding=None):
def days(self):
return TimespanBinder._seqGenerator(weeutil.weeutil.genDaySpans, self.timespan,
self.db_lookup, data_binding,
self.db_lookup, self.data_binding,
'day', self.formatter, self.converter, **self.option_dict)
# Iterate over months in the time period:
def months(self, data_binding=None):
def months(self):
return TimespanBinder._seqGenerator(weeutil.weeutil.genMonthSpans, self.timespan,
self.db_lookup, data_binding,
self.db_lookup, self.data_binding,
'month', self.formatter, self.converter, **self.option_dict)
# Iterate over years in the time period:
def years(self, data_binding=None):
def years(self):
return TimespanBinder._seqGenerator(weeutil.weeutil.genYearSpans, self.timespan,
self.db_lookup, data_binding,
self.db_lookup, self.data_binding,
'year', self.formatter, self.converter, **self.option_dict)
# Static method used to implement the iteration:

View File

@@ -41,6 +41,9 @@ Fixes issue #343.
Fixed a bug that caused a divide-by-zero error if a plot range was the same as
a specified min or max scale. Fixes issue #344.
Fixed bug that prevented an optional data_binding from being used in tags
when iterating over records. Fixes issue #345.
3.8.3 MM/DD/YYYY