annotate 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
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
9
9a0a9fa7f91d Dodałem prototyp listy zadań w systemie
Michał Rudowicz <michal.rudowicz@fl9.eu>
parents: 2
diff changeset
7 from mfrontend.views.jobcontrol import jobcontrol
1
michalr
parents:
diff changeset
8 from mfrontend import db, utils
michalr
parents:
diff changeset
9
michalr
parents:
diff changeset
10
michalr
parents:
diff changeset
11 #-- konfiguracja
2
e0061735c327 Usunąłem nieskończoną pętlę
michalr
parents: 1
diff changeset
12 config = SafeConfigParser()
1
michalr
parents:
diff changeset
13 while True:
michalr
parents:
diff changeset
14 try:
2
e0061735c327 Usunąłem nieskończoną pętlę
michalr
parents: 1
diff changeset
15 config.read('config.ini')
1
michalr
parents:
diff changeset
16 DATABASE = config.get('Basic', 'Database')
michalr
parents:
diff changeset
17 DEBUG = config.getboolean('Basic', 'Debug')
michalr
parents:
diff changeset
18 SECRET_KEY = config.get('Basic', 'Secret_Key')
michalr
parents:
diff changeset
19 break
2
e0061735c327 Usunąłem nieskończoną pętlę
michalr
parents: 1
diff changeset
20 except NoSectionError:
1
michalr
parents:
diff changeset
21 utils.default_ini()
michalr
parents:
diff changeset
22 #-- koniec konfiguracji
michalr
parents:
diff changeset
23
michalr
parents:
diff changeset
24 app = flask.Flask(__name__)
michalr
parents:
diff changeset
25 app.register_module(frontend)
9
9a0a9fa7f91d Dodałem prototyp listy zadań w systemie
Michał Rudowicz <michal.rudowicz@fl9.eu>
parents: 2
diff changeset
26 app.register_module(jobcontrol, url_prefix="/jobs")
1
michalr
parents:
diff changeset
27 app.config.from_object(__name__)
michalr
parents:
diff changeset
28 app.config.from_envvar('MFRONTEND_SETTINGS', silent=True)
michalr
parents:
diff changeset
29
michalr
parents:
diff changeset
30 @app.before_request
michalr
parents:
diff changeset
31 def before_request():
michalr
parents:
diff changeset
32 """Funkcja wywoływana zawsze przed wykonaniem żądania"""
michalr
parents:
diff changeset
33 db.connect_db()
michalr
parents:
diff changeset
34
michalr
parents:
diff changeset
35 @app.after_request
michalr
parents:
diff changeset
36 def after_request(response):
michalr
parents:
diff changeset
37 db.disconnect_db()
michalr
parents:
diff changeset
38 return response