aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-05-08 14:35:31 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-05-08 14:35:31 -0500
commit3810309443899e92d640fb0c893018ef82b786ee (patch)
treef877df48ffde7049320122292f68fe3608481e26 /mediagoblin/tools
parentf65bf8983611b18ec3a6a042404c50b8558529df (diff)
downloadmediagoblin-3810309443899e92d640fb0c893018ef82b786ee.tar.lz
mediagoblin-3810309443899e92d640fb0c893018ef82b786ee.tar.xz
mediagoblin-3810309443899e92d640fb0c893018ef82b786ee.zip
The beginning of context hooks.
Not the working solution, but getting there conceptually. Basically we'll have a key with the view and the template as a tuple which is the context hook that anyone can attach to. However, some changes have still to be made: - The unit test doesn't work yet and contains a set_trace ;) - We'll probably switch the "view" component from being the callable to the "urlgen"'able name per Elrond's suggestion - Found a bug in unit tests related to running custom apps for different configs... hm. I need to fix this! Nonetheless, making progress. This commit sponsored by... wait a minute... Christopher Webber?!
Diffstat (limited to 'mediagoblin/tools')
-rw-r--r--mediagoblin/tools/template.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/mediagoblin/tools/template.py b/mediagoblin/tools/template.py
index 54aeac92..84fdabf2 100644
--- a/mediagoblin/tools/template.py
+++ b/mediagoblin/tools/template.py
@@ -27,7 +27,8 @@ from mediagoblin import messages
from mediagoblin import _version
from mediagoblin.tools import common
from mediagoblin.tools.translate import set_thread_locale
-from mediagoblin.tools.pluginapi import get_hook_templates
+from mediagoblin.tools.pluginapi import (
+ get_hook_templates, hook_transform)
from mediagoblin.tools.timesince import timesince
from mediagoblin.meddleware.csrf import render_csrf_form_token
@@ -103,6 +104,12 @@ def render_template(request, template_path, context):
rendered_csrf_token = render_csrf_form_token(request)
if rendered_csrf_token is not None:
context['csrf_token'] = render_csrf_form_token(request)
+
+ # allow plugins to do things to the context
+ context = hook_transform(
+ (request.controller, template_path),
+ context)
+
rendered = template.render(context)
if common.TESTS_ENABLED: