From 2264670357754ae546ed69e3c825da8860b372aa Mon Sep 17 00:00:00 2001 From: Caleb Forbes Davis V Date: Mon, 27 Jun 2011 13:13:52 -0500 Subject: adds message queue Feature #368 - messaging framework * message levels are debug, info, success, warning, and error * display mechanism - base.html includes messages.html for now * fetch_messages and add_message are available to all templates using jinja2 environment.globals * messages are displayed and cleared. no persistence --- mediagoblin/util.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mediagoblin/util.py') diff --git a/mediagoblin/util.py b/mediagoblin/util.py index 91fbee0a..f0229300 100644 --- a/mediagoblin/util.py +++ b/mediagoblin/util.py @@ -32,6 +32,7 @@ from lxml.html.clean import Cleaner import markdown from mediagoblin import mg_globals +from mediagoblin import messages from mediagoblin.db.util import ObjectId TESTS_ENABLED = False @@ -104,6 +105,12 @@ def get_jinja_env(template_loader, locale): mg_globals.translations.gettext, mg_globals.translations.ngettext) + # All templates will know how to ... + # ... add a new message to the message queue + template_env.globals['add_message'] = messages.add_message + # ... fetch all waiting messages and remove them from the queue + template_env.globals['fetch_messages'] = messages.fetch_messages + if exists(locale): SETUP_JINJA_ENVS[locale] = template_env -- cgit v1.2.3