- for source, source_config in update_config.iteritems():
- hook_name = 'frontpage_updates_' + source_config['__type__']
-
- # Merge with the global config
- merged_config = source_config.copy()
- del merged_config['__type__']
-
- merged_config['limit'] = min(
- merged_config.get('limit', global_limit),
- global_limit,
- )
-
- try:
- local_max_age = now - datetime.timedelta(
- seconds=merged_config['max_age'])
- except KeyError:
- local_max_age = None
-
- if global_max_age and local_max_age:
- merged_config['max_age'] = max(global_max_age, local_max_age)
- else:
- merged_config['max_age'] = global_max_age or local_max_age
-
- # XXX bleh
- updates_lol = run_hooks(hook_name, **merged_config)
- source_obj = updates_lol[0]
- updates += source_obj.poll(merged_config['limit'], merged_config['max_age'])
-
- # Little optimization: maximum age effectively becomes the age of
- # the oldest thing that would still appear on the page, as anything
- # older would drop off the end no matter what.
- # So sort by descending time and crop each iteration...
+ global_limit = config['spline-frontpage.limit']
+ global_max_age = max_age_to_datetime(
+ config['spline-frontpage.max_age'])
+
+ c.sources = config['spline-frontpage.sources']
+ for source in c.sources:
+ new_updates = source.poll(global_limit, global_max_age)
+ updates.extend(new_updates)
+
+ # Little optimization: once there are global_limit items, anything
+ # older than the oldest cannot possibly make it onto the list. So,
+ # bump global_max_age to that oldest time if this is ever the case.