From 6d5d8e3f173cfe75a86edc0d663f8f6be3ef4351 Mon Sep 17 00:00:00 2001 From: Eevee Date: Sun, 22 Aug 2010 17:57:12 -0700 Subject: [PATCH] Upgrade to Pylons 1.0. #283 --- splinext/frontpage/__init__.py | 7 +++++-- splinext/frontpage/controllers/frontpage.py | 2 +- splinext/frontpage/sources.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/splinext/frontpage/__init__.py b/splinext/frontpage/__init__.py index 9661906..9821f9c 100644 --- 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') -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. + + 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) @@ -61,7 +64,7 @@ def load_sources_hook(*args, **kwargs): 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 diff --git a/splinext/frontpage/controllers/frontpage.py b/splinext/frontpage/controllers/frontpage.py index fee79aa..c9f779a 100644 --- a/splinext/frontpage/controllers/frontpage.py +++ b/splinext/frontpage/controllers/frontpage.py @@ -2,7 +2,7 @@ import datetime import logging from pylons import config, request, response, session, tmpl_context as c, url -from pylons.controllers.util import abort, redirect_to +from pylons.controllers.util import abort, redirect from routes import request_config from sqlalchemy.orm.exc import NoResultFound diff --git a/splinext/frontpage/sources.py b/splinext/frontpage/sources.py index a65e3e8..21c6270 100644 --- a/splinext/frontpage/sources.py +++ b/splinext/frontpage/sources.py @@ -56,7 +56,7 @@ class Source(object): The template will be passed one parameter: the update object, ``update``. """ - def __init__(self, title, icon, link, limit=None, max_age=None): + def __init__(self, config, title, icon, link, limit=None, max_age=None): self.title = title self.icon = icon self.link = link -- 2.7.4