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

(none)
author michalr
date Tue, 22 Feb 2011 18:10:18 +0000
parents
children e0061735c327
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/frontend/mfrontend/__init__.py	Tue Feb 22 18:10:18 2011 +0000
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import flask
+import ConfigParser
+from mfrontend.views.frontend import frontend
+from mfrontend import db, utils
+
+
+#-- konfiguracja
+config = ConfigParser.SafeConfigParser()
+config.read('config.ini')
+while True:
+    try:
+        DATABASE = config.get('Basic', 'Database')
+        DEBUG = config.getboolean('Basic', 'Debug')
+        SECRET_KEY = config.get('Basic', 'Secret_Key')
+        break
+    except ConfigParser.NoSectionError:
+        utils.default_ini()
+#-- koniec konfiguracji
+
+app = flask.Flask(__name__)
+app.register_module(frontend)
+app.config.from_object(__name__)
+app.config.from_envvar('MFRONTEND_SETTINGS', silent=True)
+
+@app.before_request
+def before_request():
+    """Funkcja wywoływana zawsze przed wykonaniem żądania"""
+    db.connect_db()
+
+@app.after_request
+def after_request(response):
+    db.disconnect_db()
+    return response