comparison frontend/mfrontend/__init__.py @ 1:c3fb1e9fc1f7

(none)
author michalr
date Tue, 22 Feb 2011 18:10:18 +0000
parents
children e0061735c327
comparison
equal deleted inserted replaced
0:ebb283da07f7 1:c3fb1e9fc1f7
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 import flask
5 import ConfigParser
6 from mfrontend.views.frontend import frontend
7 from mfrontend import db, utils
8
9
10 #-- konfiguracja
11 config = ConfigParser.SafeConfigParser()
12 config.read('config.ini')
13 while True:
14 try:
15 DATABASE = config.get('Basic', 'Database')
16 DEBUG = config.getboolean('Basic', 'Debug')
17 SECRET_KEY = config.get('Basic', 'Secret_Key')
18 break
19 except ConfigParser.NoSectionError:
20 utils.default_ini()
21 #-- koniec konfiguracji
22
23 app = flask.Flask(__name__)
24 app.register_module(frontend)
25 app.config.from_object(__name__)
26 app.config.from_envvar('MFRONTEND_SETTINGS', silent=True)
27
28 @app.before_request
29 def before_request():
30 """Funkcja wywoływana zawsze przed wykonaniem żądania"""
31 db.connect_db()
32
33 @app.after_request
34 def after_request(response):
35 db.disconnect_db()
36 return response