annotate frontend/mfrontend/__init__.py @ 2:e0061735c327

Usunąłem nieskończoną pętlę
author michalr
date Tue, 22 Feb 2011 18:37:32 +0000
parents c3fb1e9fc1f7
children 9a0a9fa7f91d
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
2
e0061735c327 Usunąłem nieskończoną pętlę
michalr
parents: 1
diff changeset
5 from ConfigParser import SafeConfigParser, NoSectionError
1
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
2
e0061735c327 Usunąłem nieskończoną pętlę
michalr
parents: 1
diff changeset
11 config = SafeConfigParser()
1
michalr
parents:
diff changeset
12 while True:
michalr
parents:
diff changeset
13 try:
2
e0061735c327 Usunąłem nieskończoną pętlę
michalr
parents: 1
diff changeset
14 config.read('config.ini')
1
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
2
e0061735c327 Usunąłem nieskończoną pętlę
michalr
parents: 1
diff changeset
19 except NoSectionError:
1
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