Пример #1
0
 def _data(self, filtered=True, excluded=False):
     measure = provider_measure(self)
     if measure is None:
         return []
     dataset_uid = getattr(self, 'dataset', None)
     dataset = resolve_uid(dataset_uid)
     if getattr(dataset, 'portal_type', None) != DATASET_TYPE:
         return []  # no dataset or wrong type
     infos = measure.dataset_points(dataset)  # list of info dicts
     if not infos:
         return []
     _key = lambda info: info.get('start')  # datetime.date
     if self.pointcls == NamedDataPoint:
         _key = lambda info: info.get('title')
     _point = lambda info: self.pointcls(
         _key(info),
         info.get('value'),
         note=measure.value_note(info),
         uri=info.get('url', None),
     )
     all_points = map(_point, infos)
     if filtered and not excluded:
         all_points = self.filter_data(all_points)
     if excluded:
         included = self.filter_data(all_points)
         all_points = [p for p in all_points if p not in included]
     return self.summarize(all_points)
Пример #2
0
 def _data(self, filtered=True, excluded=False):
     measure = provider_measure(self)
     if measure is None:
         return []
     dataset_uid = getattr(self, 'dataset', None)
     dataset = resolve_uid(dataset_uid)
     if getattr(dataset, 'portal_type', None) != DATASET_TYPE:
         return []  # no dataset or wrong type
     infos = measure.dataset_points(dataset)  # list of info dicts
     if not infos:
         return []
     _key = lambda info: info.get('start')  # datetime.date
     if self.pointcls == NamedDataPoint:
         _key = lambda info: info.get('title')
     _point = lambda info: self.pointcls(
         _key(info),
         info.get('value'),
         note=measure.value_note(info),
         uri=info.get('url', None),
         )
     all_points = map(_point, infos)
     if filtered and not excluded:
         all_points = self.filter_data(all_points)
     if excluded:
         included = self.filter_data(all_points)
         all_points = [p for p in all_points if p not in included]
     return self.summarize(all_points)
Пример #3
0
 def pointcls(self):
     """
     Use re-acquisition of self via catalog to ensure proper
     acquisition wrapping, get point class to use based on the
     acquisition parent (chart) type containing this provider.
     """
     own_uid = IUUID(self)
     wrapped = resolve_uid(own_uid)
     if wrapped is None:
         return TimeSeriesDataPoint  # fallback!
     parent = aq_parent(aq_inner(self))
     if INamedSeriesChart.providedBy(parent):
         return NamedDataPoint
     return TimeSeriesDataPoint
Пример #4
0
 def get_theme(self):
     uid = self.request.get("theme", None)
     if uid is None:
         return None  # sentinel for defaults
     return resolve_uid(uid)
Пример #5
0
 def get_theme(self):
     uid = self.request.get('theme', None)
     if uid is None:
         return None  # sentinel for defaults
     return resolve_uid(uid)