- # Hooks should return a list of FrontPageUpdate objects, making this
- # return value a list of lists
- updates_lol = run_hooks('frontpage_updates', limit=10)
- updates = sum(updates_lol, [])
+ # XXX no reason to do this on the fly; cache it on server startup
+ update_config = defaultdict(dict) # source_name => config
+ key_rx = re.compile(
+ '(?x) ^ spline-frontpage [.] sources [.] (\w+) (?: [.] (\w+) )? $')
+ for key, val in config.iteritems():
+ match = key_rx.match(key)
+ if not match:
+ continue
+
+ source_name, subkey = match.groups()
+ if not subkey:
+ # This is the type declaration; use a special key
+ subkey = '__type__'
+
+ update_config[source_name][subkey] = val
+
+
+ global_config = dict(
+ limit = 10,
+ )
+
+ # Ask plugins to deal with this stuff for us!
+ updates = []
+ for source, source_config in update_config.iteritems():
+ source_config2 = source_config.copy()
+ hook_name = 'frontpage_updates_' + source_config2.pop('__type__')
+ source_config2.update(global_config)
+
+ # Hooks should return a list of FrontPageUpdate objects, making this
+ # return value a list of lists
+ updates_lol = run_hooks(hook_name, **source_config2)
+ updates += sum(updates_lol, [])