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

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