projects
/
zzz-spline-frontpage.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't raise when an RSS source is down.
[zzz-spline-frontpage.git]
/
splinext
/
frontpage
/
__init__.py
diff --git
a/splinext/frontpage/__init__.py
b/splinext/frontpage/__init__.py
index
e113e74
..
9821f9c
100644
(file)
--- a/
splinext/frontpage/__init__.py
+++ b/
splinext/frontpage/__init__.py
@@
-16,9
+16,12
@@
def add_routes_hook(map, *args, **kwargs):
"""Hook to inject some of our behavior into the routes configuration."""
map.connect('/', controller='frontpage', action='index')
"""Hook to inject some of our behavior into the routes configuration."""
map.connect('/', controller='frontpage', action='index')
-def load_sources_hook(*args, **kwargs):
+def load_sources_hook(
config,
*args, **kwargs):
"""Hook to load all the known sources and stuff them in config. Run once,
on server startup.
"""Hook to load all the known sources and stuff them in config. Run once,
on server startup.
+
+ Frontpage hooks are also passed the `config` hash, as it's not available
+ during setup.
"""
# Extract source definitions from config and store as source_name => config
update_config = defaultdict(dict)
"""
# Extract source definitions from config and store as source_name => config
update_config = defaultdict(dict)
@@
-61,11
+64,17
@@
def load_sources_hook(*args, **kwargs):
source_config.setdefault('max_age', global_max_age)
# Hooks return a list of sources; combine with running list
source_config.setdefault('max_age', global_max_age)
# Hooks return a list of sources; combine with running list
- sources += run_hooks(hook_name, **source_config)
+ sources += run_hooks(hook_name,
config=config,
**source_config)
# Save the list of sources, and done
config['spline-frontpage.sources'] = sources
# Save the list of sources, and done
config['spline-frontpage.sources'] = sources
+def source_cron_hook(*args, **kwargs):
+ """Hook to pass on cron tics to all sources, should they need it for e.g.
+ caching.
+ """
+ for source in config['spline-frontpage.sources']:
+ source.do_cron(*args, **kwargs)
class FrontPagePlugin(PluginBase):
def controllers(self):
class FrontPagePlugin(PluginBase):
def controllers(self):
@@
-82,6
+91,7
@@
class FrontPagePlugin(PluginBase):
return [
('routes_mapping', Priority.NORMAL, add_routes_hook),
('after_setup', Priority.NORMAL, load_sources_hook),
return [
('routes_mapping', Priority.NORMAL, add_routes_hook),
('after_setup', Priority.NORMAL, load_sources_hook),
+ ('cron', Priority.NORMAL, source_cron_hook),
('frontpage_updates_rss', Priority.NORMAL, FeedSource),
('frontpage_updates_git', Priority.NORMAL, GitSource),
]
('frontpage_updates_rss', Priority.NORMAL, FeedSource),
('frontpage_updates_git', Priority.NORMAL, GitSource),
]