exc.get_description(environ))(environ, start_response)
controller = endpoint_to_controller(found_rule)
+ # Make a reference to the controller on the request...
+ # used for lazy context modification
+ request.controller = controller
# pass the request through our meddleware classes
try:
from mediagoblin.init.plugins import setup_plugins
from mediagoblin.init.config import read_mediagoblin_config
from mediagoblin.tools import pluginapi
+from mediagoblin.tests.tools import get_app
def with_cleanup(*modules_to_delete):
# the callables thing shouldn't really have anything though.
assert len(config['plugins'][
'mediagoblin.tests.testplugins.callables1']) == 0
+
+
+@pytest.fixture()
+def context_modified_app(request):
+ get_app(
+ request,
+ mgoblin_config=pkg_resources.resource_filename(
+ 'mediagoblin.tests', 'appconfig_context_modified.ini'))
+
+def test_modify_context(context_modified_app):
+ pytest.set_trace()
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
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: