[library-web] [lgoweb] redirect to / on invalid key



commit c993159cc481492cf2dacdb3ecd045260fc79cfc
Author: Frédéric Péters <fpeters 0d be>
Date:   Wed Apr 6 17:13:26 2011 +0530

    [lgoweb] redirect to / on invalid key

 web/api.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/web/api.py b/web/api.py
index 9f0b42b..b9bb1f6 100644
--- a/web/api.py
+++ b/web/api.py
@@ -50,7 +50,10 @@ def lookup(request):
     return HttpResponse(response, mimetype="text/plain")
 
 def redirect(request):
-    symbol = request.REQUEST['q']
+    try:
+        symbol = request.REQUEST['q']
+    except KeyError:
+        return HttpResponseRedirect('/')
     sqlcon = get_sqlconn()
     cur = sqlcon.cursor()
     cur.execute('select path from symbols where symbol = ? limit 1', (symbol,))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]