annotate frontend/mfrontend/__init__.py @ 23:b75a9ae3a060

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