From dc36e320ef4d90b0bf802c6b54877971e2249d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sun, 15 Jan 2012 11:12:11 +0100 Subject: Do not load JS for mobile browsers --- index.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'index.py') diff --git a/index.py b/index.py index 1639fc4..a7d32d9 100755 --- a/index.py +++ b/index.py @@ -38,14 +38,24 @@ def handle_sql(handler): web.ctx.orm.commit() return h +# +# Check for mobile (at least somewhat) +# +mobile_checks = ["J2ME", "Opera Mini"] +def handle_mobile(): + ua = web.ctx.env.get("HTTP_USER_AGENT", "") + + web.ctx.is_mobile = any((x in ua) for x in mobile_checks) + # # The App # app = web.application(urls, globals()) app.notfound = controller.FourOhFour.catch -# add orm processor +# add processors app.add_processor(handle_sql) +app.add_processor(web.loadhook(handle_mobile)) # debug for the moment web.config.debug = True -- cgit v1.2.3