summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/index.py b/index.py
index 813e79b..f6e08e1 100644
--- a/index.py
+++ b/index.py
@@ -46,7 +46,11 @@ def closedb(req):
# start a new session and context and register the session dictionary in our
# global template context
def session_start(req, anonymous):
- req.dbc = MySQLdb.connect(host="localhost", user="apache", passwd="password", db="trac")
+ try:
+ req.dbc = MySQLdb.connect(host="localhost", user="apache", passwd="password", db="trac")
+ except:
+ redirect(req, "db_error")
+
req.cursor = req.dbc.cursor()
req.register_cleanup(closedb, req)