Source

lodgeit-main / lodgeit / application.py

Full commit
# -*- coding: utf-8 -*-
"""
    lodgeit.application
    ~~~~~~~~~~~~~~~~~~~

    the WSGI application

    :copyright: 2007-2009 by Armin Ronacher, Christopher Grebs.
    :license: BSD
"""
import flask
from flask.ext.babel import Babel

app = flask.Flask('lodgeit')
babel = Babel(app)


from .i18n import list_languages


@app.context_processor
def inject_i18n_languages():
    return {'i18n_languages': list_languages()}


@app.context_processor
def inject_style():
    style, css = get_style(request)
    return {'style': style, 'css': css}


@app.context_processor
def inject_new_replies():
    if flask.request.method=='GET':
        from lodgeit.models import Paste
        return {'new_replies': Paste.fetch_replies()}


@app.errorhandler(404)
def not_found(e):
    return flask.render_template('not_found.html')


from lodgeit import controllers
for blueprint in controllers.all:
    app.register_blueprint(blueprint)