view frontend/mfrontend/__init__.py @ 9:9a0a9fa7f91d

Dodałem prototyp listy zadań w systemie
author Michał Rudowicz <michal.rudowicz@fl9.eu>
date Mon, 28 Feb 2011 19:25:51 +0100
parents e0061735c327
children 69ecfe51d585
line wrap: on
line source

#!/usr/bin/python
# -*- coding: utf-8 -*-

import flask
from ConfigParser import SafeConfigParser, NoSectionError
from mfrontend.views.frontend import frontend
from mfrontend.views.jobcontrol import jobcontrol
from mfrontend import db, utils


#-- konfiguracja
config = SafeConfigParser()
while True:
    try:
        config.read('config.ini')
        DATABASE = config.get('Basic', 'Database')
        DEBUG = config.getboolean('Basic', 'Debug')
        SECRET_KEY = config.get('Basic', 'Secret_Key')
        break
    except NoSectionError:
        utils.default_ini()
#-- koniec konfiguracji

app = flask.Flask(__name__)
app.register_module(frontend)
app.register_module(jobcontrol, url_prefix="/jobs")
app.config.from_object(__name__)
app.config.from_envvar('MFRONTEND_SETTINGS', silent=True)

@app.before_request
def before_request():
    """Funkcja wywoływana zawsze przed wykonaniem żądania"""
    db.connect_db()

@app.after_request
def after_request(response):
    db.disconnect_db()
    return response