forked from kjam/random_hackery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmobile.py
More file actions
executable file
·14 lines (13 loc) · 734 Bytes
/
mobile.py
File metadata and controls
executable file
·14 lines (13 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class MobileMiddleware(object):
'''This is a simple mobile middleware wrapper for Django that uses separate caching environments for mobile vs. standard browser interactions'''
def process_request(self,request):
if 'HTTP_USER_AGENT' in request.META:
touch = (lambda x:'iPad' in x or 'iPhone' in x or 'Android' in x or False)(request.META['HTTP_USER_AGENT'])
ipad = (lambda x:'iPad' in x or False)(request.META['HTTP_USER_AGENT'])
if ipad:
CACHE_MIDDLEWARE_KEY_PREFIX = '542378909#$'
elif touch:
CACHE_MIDDLEWARE_KEY_PREFIX = '5589043cjkowio'
return None
def process_response(self, request, response):
return response